| zi_repair | R Documentation |
This function repairs two of the four conditions identified
in the validation checks with zi_validate(). For the other two
conditions, values are conveted NA. See Details below for the
specific changes made.
zi_repair(x, style = "zcta5")
x |
A vector containing ZIP or ZCTA values to be repaired. |
style |
A character scalar - either |
The zi_repair() function addresses four conditions:
If the input vector is numeric, it will be converted to character data.
If there are values less than five characters (if style = "zcta5",
the default), or three characters (if style = "zcta3"), they will
be padded with leading zeros.
If there are input values over five characters (if style = "zcta5",
the default), or three characters (if style = "zcta3"), they will
be converted to NA.
If there are input values that have non-numeric characters, they will
be converted to NA.
Since two of the four steps will result in NA values, it is strongly
recommended to attempt to manually fix these issues first.
A repaired vector of ZIP or ZCTA values.
# sample five-digit ZIPs with character
zips <- c("63088", "63108", "zip")
# failed validation
zi_validate(zips)
# repair
zips <- zi_repair(zips)
# successful validation
zi_validate(zips)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.