Error in R data read

Hi all - new user of IPUMS here (and sorry if this is a repost).

I’m using IPUMS USA for a data project, and I’m encountering an error when trying to read my data into R. I’m using the following code (per the training exercises/other user posts)


ddi <- read_ipums_ddi(“usa_00008.dat”)
data <- read_ipums_micro(ddi)

And getting a the following error “Start tag expected, ‘<’ not found [4].” I’ve decompressed my data file from a dat.gz -> .dat, and I’ve downloaded the data into my working directory. If anyone could point me in the right direction, that would be appreciated!

Welcome to IPUMS! In order to read your data using R, ensure that the following are true:

  1. You have downloaded the DDI file as an XML file (right-click on the link titled ‘DDI’ > Save Link As)
  2. Both the .dat file (data file) and .xml file (ddi codebook) are saved in the same folder as your R project (your working directory)
  3. The ipumsr package has been installed and loaded (install.packages(‘ipumsr’) and library(ipumsr))

These instructions are outlined in more detail here.

Your code should look something like this (the main difference being that the .xml file should be called in the read_ipums_ddi function):

#Install and load ipumsr package

#Load the data
ddi <- read_ipums_ddi(“usa_00008.xml”)
data <- read_ipums_micro(ddi)

#View a summary of the data

Hi there,

I used the exact code supplied with the data (same syntax as the chunk you provided) and am getting the following error:

Code entered:
ddi <- read_ipums_ddi(‘usa_00001.xml’)
data <- read_ipums_micro(ddi)

“Error: Can’t combine ..1$val < character > and ..2$val < double >.”

I have installed and loaded the ipumsr package. I have uploaded the .dat file, the R file, and the DDI (in the form of an .xml file) associated with my dataset to R and they are in the same folder, which is the working directory. And the filename used is correct.

Any guidance on this would be greatly appreciated.

1 Like

I am encountering the same issue, hoping someone could help.

This issue has come up recently and can be fixed by reinstalling the development version of ipumsr from Github with the following commands:

> if (!require(remotes)) install.packages("remotes")
> remotes::install_github("mnpopcenter/ipumsr")

We will be releasing the development version to CRAN soon, so that users don’t need to install from GitHub to avoid this error in the future.