I have census tract data, and I want to add leading zeros if the value is less than 6 digits, including the two zeroes that come after the decimal point. I tried using str_pad
, but that adds zeroes to the observations that already have 6 digits (and gets rid of the .00).
I think what's happening is that it's not counting the "00" after the decimal point as digits. How do I make sure that the zeroes after the decimal point are being counted?
Data:
31 9806.00
32 9808.00
33 9806.00
34 201.00
35 201.00
36 206.00
37 209.00
38 201.00
39 201.00
40 209.00
How I want it to look:
31 9806.00
32 9808.00
33 9806.00
34 0201.00
35 0201.00
36 0206.00
37 0209.00
38 0201.00
39 0201.00
40 0209.00