Skip to contents

Ensures FIPS has the leading zero, but does NOT VALIDATE FIPS - It does NOT check if FIPS is valid other than checking its length. fips could be a state, county, tract, blockgroup, or block FIPS code.

Usage

fips_lead_zero(fips)

Arguments

fips

vector of numeric or character US FIPS codes

Value

vector of same length

Examples

testfips1 <- c(1,"01",1234,"1234","12345",123456)
testfips <- c(1, "1", "12", "123", "1234", "12345", "", NA, "words")
fips_lead_zero(testfips1)
#> [1] "01"      "01"      "01234"   "01234"   "12345"   "0123456"
fips_lead_zero(testfips)
#> Warning: 4 fips had invalid number of characters (digits) or were NA values
#> [1] "01"    "01"    "12"    NA      "01234" "12345" NA      NA      NA