简体   繁体   中英

Reading SPSS (.sav) dataset into R with haven and getting errors

I'm trying to load an SPSS data set (.sav) into R using the Haven package and can't get it to work.

I'm running R version 3.4.4 (2018-03-15) -- "Someone to Lean On" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit)

on OS 10.15.7

I've loaded Haven:

install.packages('haven', repos="http://cran.rstudio.com/", dependencies=TRUE)

Loaded all of the dependencies, and "install[ed] from sources the packages which need compilation."

Got lots of warnings like this one:

 Warning in install.packages :
  installation of package ‘diffobj’ had non-zero exit status 

Tried to load the file using this:

df <- read_spss('file.sav')

also tried

df <- read_sav('file.sav')

get this error:

Error in read_sav("file.sav") : 
  could not find function "read_sav"

At one point it looked like I was missing a package called Pillar, so I added that (but it still didn't work). Then I added the bit of code to downloading Haven about dependencies so figured that should resolve that.

What am I missing?

Thanks.

We could install the additional packages needed. Based on the OP's post, the R version is old. The current version is R 4.1.0 . Would recommend to update the R and then install

install.packages('diffobj')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM