lead.zeroes | R Documentation |
Returns the vector that was supplied, but with leading zeroes added where needed to make all elements have right number of characters.
lead.zeroes(fips, length.desired = NULL)
fips |
Character vector, which can be FIPS codes or other data. Required. |
length.desired |
NOT USED ANYMORE. INFERRED. Was a single numeric value (recycled), or vector of numbers, required, specifying how many characters long each returned string should be. |
This function can be useful in working with Census data where FIPS codes are often used.
Moving data to and from a spreadsheet can remove leading zeroes that may be necessary for proper data management.
This can apply to e.g., FIPS code for a block, block group, tract, county, or state.
Note: Number of digits in FIPS codes, assuming leading zeroes are there:
state 2 (2 cumulative)
county 3 (5 cum)
tract 6 (11 cum) (note 11 digits is ambiguous if not sure leading zero is there)
block group 1 (12 cum) (note 12 digits is ambiguous if not sure leading zero is there)
block 1 (13 cum)
Returns a vector of same length as input parameter, NA for NA input elements
lead.zeroes(c('234','01234','3', NA, 'TEXT'), 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.