Reading .sav file into R
Asked Answered
D

3

45

I am trying to read a .sav file into R but I got the following warning:

library("memisc")
dataset <- data.frame(as.data.set(spss.system.file("dataset.sav")))

parseSysHeader(ptr) : file lacks info_flt64 record, using defaults

Could someone tell me what this warning means and how to fix it? Any help would be appreciated.

Thank you

Takahiro

Dermatome answered 8/10, 2015 at 21:23 Comment(0)
B
69

You can also use the 'haven' package to read in the SPSS file. This package has much more consistency over the foreign package, with regard to syntax. Also, the resulting data frame will have both the 'tbl_df' and 'tbl' classes so printing will be improved if dplyr is loaded.

library(haven)

path = file.path("C:/", "Folder", "dataset.sav")
dataset = read_sav(path)
Bashuk answered 21/4, 2016 at 16:26 Comment(1)
You can try this code too. So you can do it effortlessly without typing path. dataset=read_sav(file.choose())Enchiridion
S
25

You can use the library foreign to import data from .sav (SPSS) format.

library(foreign)

data <- read.spss("C:/PathToFile/dataset.sav", to.data.frame=TRUE)
Shutin answered 21/4, 2016 at 16:15 Comment(0)
F
6

Another option could be my R package readspss. The syntax is similar to the one of the foreign package. The imported data is returned as a data.frame() with attributes. The package was written from scratch and features read and write support for all SPSS files (zsav, sav and por). It was tested with a variety of SPSS files and supports reading of (hopefully) all SPSS features (e.g. encrypted and or compressed files, long strings, and all types of missings).

library(readspss)
dataset <- read.sav("dataset.sav")
Footpound answered 7/11, 2019 at 21:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.