简体   繁体   中英

How to read a .sav SPSS file in in R?

I've tried read.spps() , but I get an encoding error:

library(foreign)
read.spss('persona.sav')
#>re-encoding from CP1252

Error in iconv(names(rval), cp, "") : unsupported conversion from 'CP1252' to '' In addition: Warning message: In read.spss("persona.sav") : persona.sav: Unrecognized record type 7, subtype 18 encountered in system file

Try re-encoding it as a utf-8 file:

 library(foreign)
 read.spss('persona.sav', reencode='utf-8')

You can try adding 'to.data.frame = TRUE' into read.spss()

For instance:

df <- read.spss("data.sav", to.data.frame = TRUE)

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