Skip to contents

FIPS - Identify what type of Census geography each FIPS code seems to be (block, county, etc.)

Usage

fipstype(fips)

Arguments

fips

vector of one or more Census FIPS with or without leading zeroes, as strings or numeric

Value

vector of types: "block", "blockgroup", "tract", "city", "county", or "state"

Details

NOTE: Does NOT check if fips is a real fips. For that, use fips_valid()

Note a number of length 11 is an ambiguous case this is able to resolve as either a complete tract fips or a blockgroup fips with a missing leading zero.

Examples

 fips_counties_from_statename("Delaware")
 fipstype(9001)
 fipstype("10001")
 
test_tract_missing0 =   4013116500   # 10 digits tract missing 0
test_tract_good     = "04013116500"  # 11 digits full tract includes leading 0 !!!!!!!!!!
test_bg_missing0    =   40131165002  # 11 digits blockgroup missing leading 0 !!!!!!!!!!
test_bg_good        = "040131165002" # 12 digits full blockgroup

fipstype(test_tract_missing0)
fipstype(test_tract_good)
fipstype(test_bg_missing0)
fipstype(test_bg_good)

fips_valid(test_tract_missing0)
fips_valid(test_bg_missing0)