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)

rm(list=ls())
library(ipumsr)

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
install.packages(‘ipumsr’)
library(ipumsr)

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

#View a summary of the data
summary(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.

1 Like

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.

1 Like

Hi Grace,

Thanks a lot for your help.
I am following the above steps and the software reports: “cannot open URL 'https://api.github.com/repos/mnpopcenter/ipumsr/commits/master”.
I checked with browser and it is fine to connect to github, so I have no idea why the error comes up.
Any guidance on this would be greatly appreciated.

The error you are encountering may be an issue with ‘remotes’, according to this Github page. Try using this code that utilizes ‘devtools’ instead, as outlined on the ipumsr tech page.

if (!require(devtools)) [install.packages]("devtools") 
devtools::install_github("mnpopcenter/ipumsr")
1 Like

Thanks, Grace!

I stopped receiving alerts for responses to my original post, so I wasn’t aware you had posted fixes. Second fix (plus a bunch of unloading/reloading of packages) finally worked for me.