spss_import: Import data set from SPSS (.sav)
Description
Read a labelled data set from SPSS, finding automatically the date variables and keeping the variable and value labels information, by using the information obtained with spss_varlist()
and the function spss.get
from the Hmisc Package.
Usage
spss_import(file, allow="_",out.format="d-m-yy",use.value.labels=F,...)
Arguments
file
The path to the file with .sav extension.
allow
A vector which contains the characters that must be allowed in the variable names.
out.format
A character specifying the format for printing the date variables.
use.value.labels
If TRUE, replace the labelled variables with their value labels.
Value
A data frame or a list containing the data stored in the SPSS file.
Details
In order to provide the maximum functionallity, if the main code generates an error, the function tries to read the file with the read_sav
function from the haven package, but a warning message appears.
The var_view
function can be used to summarize the contents of the data frame labels.
Examples
Run this code# NOT RUN {
x <- spss_import("mydata.sav")
# }
Run the code above in your browser using DataLab