Search code examples
rstatar-haven

Am I the only one experiencing problems with R's haven package?


I want to open a stata file in R, via haven::read_dta(). I'have created my script a few weeks ago and it all worked well until now: suddenly, when I try loading the data my session crashes ("R Session Aborted"). A colleague of mine is having the same problem.

I' ve tried many things: choosing the correct working directory via setwd(), choosing the file via choose.files(), entering the filepath with "/", "//" and "\" but nothing seems to work.

They way it worked until now was:

install.packages("haven")
library(haven)

my_data <- read_dta("my_path_structure\\file_name.dta")

Anyone having the same problem?

EDIT: Problem should be fixed soon. For more information see here.


Solution

  • Issue

    On the 14th, Haven updated to 2.4.0 where they internally upgraded to ReadStat 1.1.5. which handles the import of .dta files. There doesn't appear to be any codebreaking updates in ReadStat 1.1.5..

    I was able to reproduce your abort error in R Studio which gives no information. I went directly to the R Console and it gives me the following segmentation error after running the same code:

    *** caught segfault ***
    address 0x0, cause 'invalid permissions'
    

    Given that this was not an issue with the previous build of Haven, I would make a bug report with the developer.

    Temporary Solution

    I was able to get around this issue by using the readstata13 package instead. Here is an example,

    install.packages("readstata13")
    library(readstata13)
    my_data <- read.dta13("my_path_structure/file_name.dta")