clean.fips: Clean up US Census FIPS (Add Missing Leading Zeroes)

View source: R/clean.fips.R

clean.fipsR Documentation

Clean up US Census FIPS (Add Missing Leading Zeroes)

Description

Clean up US Census FIPS (add any missing leading zeroes)

Usage

clean.fips(fips)

Arguments

fips

Vector of numeric or character class, required. Can be state FIPs as number or character, for example.

Details

For information on FIPS codes, see http://www.census.gov/geo/reference/ansi.html, and also see https://www.census.gov/geo/reference/geoidentifiers.html

If FIPS provided is 1-2 digits long assume it is a State.
If FIPS provided is 3 digits long, it is a mistake and return NA.
If FIPS provided is 4-5 digits, assume it is a County.
If FIPS provided is 6-9 digits, it is a mistake and return NA.
If FIPS provided is 10 digits long, assume it is a tract missing a leading zero on the state portion (should have 11 characters).
If FIPS provided is 11 digits long, assume it is a tract (correctly 11 characters), not simply a block group FIPS missing a leading zero (block group FIPS would correctly would have 12 characters).
If FIPS provided is 12 digits long, assume it is a block group (correctly 12 characters).
If FIPS provided is 13 digits long, it is a mistake and return NA.
If FIPS provided is 14 OR 15 digits long, assume it is a block.

Value

Returns vector of FIPS (all characters from 2-digit State code onwards as appropriate) as character with leading zeroes

See Also

clean.fips()


ejanalysis/ejanalysis documentation built on April 2, 2024, 10:12 a.m.