Skip to contents

Pads GEOID columns in a data.table to required width with leading zeros. Use for preparing census codes for spatial analysis or database joins.

Usage

geoid_pad(dt)

Arguments

dt

data.table. Input with GEOID columns to pad.

Value

data.table. Copy of input with padded GEOID columns.

Details

  • Pads columns for block group, PUMA, county, and state.

  • Returns a copy; does not modify by reference.

  • Assumes columns are character or integer.

Settings

None.

See also

clip.vector

Other geo utilities: format_geoids(), get_bg_geom(), get_county_fips(), get_puma_geom(), get_state_fips(), pad_geoid_cols()

Examples

dt <- data.table(bg = c(12345678901, 23456789012))
geoid_pad(dt)
#>              bg
#>          <char>
#> 1: 012345678901
#> 2: 023456789012