Skip to contents

The Federal Information Processing Standards (fips) codes are available as 5-digit, 0-padded numbers. To standardize these codes for joins across datasets, one may need to convert raw integers (non-0-padded) to 5-digit numeric strings. This function does that.

Usage

integer_to_fips(v)

integer_to_state_fips(v)

Arguments

v

integer vector of state-level fips to be converted

Value

character vector with each member a 0-padded representation of the original integer value.

Functions

  • integer_to_state_fips():

References

List of United States FIPS codes by county: https://en.wikipedia.org/wiki/List_of_United_States_FIPS_codes_by_county.

Author

Sean Davis seandavi@gmail.com

Examples

integer_to_fips(50)
#> [1] "00050"
class(integer_to_fips(50))
#> [1] "character"
nchar(integer_to_fips(50))==5
#> [1] TRUE
integer_to_fips(sample(1:50000,5))
#> [1] "21456" "39402" "20678" "08265" "41372"


# integer to state fips
sl = integer_to_state_fips(5)
#> Error in integer_to_state_fips(5): object 'fips' not found
sl
#> Error in eval(expr, envir, enclos): object 'sl' not found
sl == '05000'
#> Error in eval(expr, envir, enclos): object 'sl' not found