import_spss {eatGADS} | R Documentation |
Import SPSS data
Description
Function to import .sav
files while extracting meta information, e.g. variable and value labels.
Usage
import_spss(
filePath,
checkVarNames = TRUE,
labeledStrings = c("drop", "keep", "transform"),
encoding = NULL
)
Arguments
filePath |
Source file location, ending on |
checkVarNames |
Should variable names be checked for violations of |
labeledStrings |
Should strings as labeled values be allowed? If |
encoding |
The character encoding used for the file. The default, |
Details
SPSS files (.sav
) store variable and value labels and assign specific formatting to variables. import_spss
imports
data from SPSS, while storing this meta-information separately in a long format data frame. Value labels and missing labels are used
to identify missing values (see checkMissings
). Time and date variables are converted to character.
In some special cases, .sav
files seem to consist of a mix of different encoding types. In such cases, haven
might
throw an error if the encoding argument is not specified or UTF-8
is selected as encoding. To circumvent this problem we
recommend using encoding = "ASCII"
and fixing the resulting issues manually. For example, fixEncoding
provides some fixes for encoding issues specific to the German language.
Value
Returns a list with the actual data dat
and a data frame with all meta information in long format labels
.
Examples
# Use spss data from within package
spss_path <- system.file("extdata", "pisa.zsav", package = "eatGADS")
pisa_gads <- import_spss(spss_path)