Share

10.13 Add leading zeros to single digit numbers to match datasets

#Sometimes we may want to "join" data and one may have single digits
#and the other may have leading zeros. We can use the "stringr" package
#to add leading zeros to only the numbers that occur in single digits

Label WMU COUNTY
14_D320 4D 7 #note COUNTY is an integer here
library(stingr)
none$COUNTY <- str_pad(none$COUNTY,2, pad = "0")
#Now the resulting data
Label WMU COUNTY
14_D320 4D 07