i've used formatc adding leading zeroes when needed i'm working census tracts require add trailing zeroes no decimal. i've read through options can't see way formatc places zeroes end without making them decimals places? thoughts appreciated.
tract<-c(1,11,101,1001,10001,100001) formatc(tract,width=6,format="d",flag="0")
you can add trailing zeros str_pad stringr package:
library(stringr) str_pad(tract, 6, "right", "0") # [1] "100000" "110000" "101000" "100100" "100010" "100001"
Comments
Post a Comment