简体   繁体   English

使用避风港将 SPSS (.sav) 数据集读入 R 并出现错误

[英]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.我正在尝试使用 Haven 包将 SPSS 数据集 (.sav) 加载到 R 中,但无法使其正常工作。

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)我正在运行 R 版本 3.4.4 (2018-03-15) -- "Someone to Lean On" 版权所有 (C) 2018 统计计算平台 R 基金会:x86_64-apple-darwin15.6.0(64 位)

on OS 10.15.7在 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."加载所有依赖项,并“从源代码安装[ed] 需要编译的包。”

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).有一次,我似乎缺少一个名为 Pillar 的包,所以我添加了它(但它仍然不起作用)。 Then I added the bit of code to downloading Haven about dependencies so figured that should resolve that.然后我添加了一些代码来下载 Haven 关于依赖项,所以我认为应该可以解决这个问题。

What am I missing?我错过了什么?

Thanks.谢谢。

We could install the additional packages needed.我们可以安装所需的额外软件包。 Based on the OP's post, the R version is old.根据 OP 的帖子, R version很旧。 The current version is R 4.1.0 .当前版本是R 4.1.0 Would recommend to update the R and then install建议更新R然后安装

install.packages('diffobj')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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