zi_validate {zippeR}R Documentation

Validate ZIP Code or ZCTA Vector

Description

This function validates vectors of ZIP Code or ZCTA values. It is used internally throughout zippeR for data validation, but is exported to facilitate troubleshooting.

Usage

zi_validate(x, style = "zcta5", verbose = FALSE)

Arguments

x

A vector containing ZIP or ZCTA values to be validated.

style

A character scalar - either "zcta5" (default) or "zcta3".

verbose

A logical scalar; if FALSE (default), an overall evaluation will be returned. If TRUE, a tibble object listing validation criteria and results will be returned.

Details

The zi_validate() function checks for four conditions:

The questions provide a basis for repairing issues identified with zi_repair().

Value

Either a logical value (if verbose = FALSE) or a tibble containing validation criteria and results.

Examples

# sample five-digit ZIPs
zips <- c("63088", "63108", "63139")

# successful validation
zi_validate(zips)

# sample five-digit ZIPs in data frame
zips <- data.frame(id = c(1:3), ZIP = c("63139", "63108", "00501"), stringsAsFactors = FALSE)

# successful validation
zi_validate(zips$ZIP)

# sample five-digit ZIPs with character
zips <- c("63088", "63108", "zip")

# failed validation
zi_validate(zips)
zi_validate(zips, verbose = TRUE)


[Package zippeR version 0.1.0 Index]