Skip to content

R session crashes when trying to read (some) text values from a Stata file with read_dta() #620

@DaniMori

Description

@DaniMori

I have a dataset in a .dta file which opens normally in Stata, and is also read normally with read_dta() in haven v.2.3.1.
However, when testing in versions 2.4.0 and 2.4.1, an "R Session Aborted" crash is produced.

I can't provide a "reprex", as when I try to reprex it, I obtain the message:

"Error: This reprex appears to crash R"

So here is the code to reproduce it:

library(tidyverse)
library(haven)

setwd("~/../OneDrive - UAM/Workspace/R_bug_reporting_and_help")

# Both one-variable datasets are read normally
q4534 <- read_dta("data/q4534.dta")
q4554 <- read_dta("data/q4554.dta")

# If I collapse them together, write them as a .dta file and read it again,
#   it works normally
both_vars <- bind_cols(q4534, q4554)
write_dta(both_vars, path = "data/test.dta")
read_dta("data/test.dta")

# However, the dataset with the original two-variable dataset crashes:
read_dta("data/q4534_q4554.dta")

The three files are attached. Note that there are two variables with two cases each, and both are text values. The bug seems to happen when both are text variables; also, you may notice my working directory is a cloud storage drive (OneDrive). I tried pausing the synchronization, in case that could be causing the problem, but it happened anyway.

data.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions