readSPSS
reads an SPSS data set, stored in a file of type .sav
or .por
, into an R data frame; it provides
a front end to the read_spss
function in the haven package and the read.spss
function in the foreign package.
readSPSS(file, rownames=FALSE, stringsAsFactors=FALSE,
tolower=TRUE, use.value.labels=TRUE, use.haven=!por)
a data frame
path to an SPSS .sav
or .por
file.
if TRUE
(the default is FALSE
), the first column in the
data set contains row names, which should be unique.
if TRUE
(the default is FALSE
) then columns containing character data are converted to
factors and factors are created from SPSS value labels.
change variable names to lowercase, default TRUE
.
if TRUE
, the default, variables with value labels in the SPSS
data set will become either factors or character variables (depending on the stringsAsFactors
argument) with the value labels as their levels or values. As for read.spss
,
this is only done if there are at least as many labels as values of the variable
(and values without a matching label are returned as NA
).
use read_spss
from the haven package to read the file,
in preference to read.spss
from the foreign package; the default is
TRUE
for a .sav
file and FALSE
for a .por
file.
John Fox jfox@mcmaster.ca
read_spss
, read.spss