Reading IPUMS USA in R

When I try to read IPUMS USA data in R, the zeros at the beginning of the variable disappear.

For example, STATEFIP needs to display Alabama=01, but Alabama=1.

To deal with such a problem, we have to use an option such as stringsAsFactors = FALSE for csv-file reading, etc. Does such an option exist in IPUMS?

If not, what should we do?

IPUMS USA treats STATEFIP as a numeric variable; accordingly, leading zeroes will generally be dropped when reading this into a stats package. If you require leading zeros for your application, you might look into str_pad() to add them after loading the data into R.

Sorry for the late reply.

Thank you for your comment!

You can use str_pad() to combine data.

Sincerely yours

1 Like