read.sav: Read SPSS File

View source: R/read.sav.R

read.savR Documentation

Read SPSS File

Description

This function calls the read_spss function in the haven package by Hadley Wickham, Evan Miller and Danny Smith (2023) to read an SPSS file.

Usage

read.sav(file, use.value.labels = FALSE, use.missings = TRUE, formats = FALSE,
         label = FALSE, labels = FALSE, missing = FALSE, widths = FALSE,
         as.data.frame = TRUE, check = TRUE)

Arguments

file

a character string indicating the name of the SPSS data file with or without file extension '.sav', e.g., "SPSS_Data.sav" or "SPSS_Data".

use.value.labels

logical: if TRUE, variables with value labels are converted into factors.

use.missings

logical: if TRUE (default), user-defined missing values are converted into NAs.

formats

logical: if TRUE, variable formats are shown in an attribute for all variables.

label

logical: if TRUE, variable labels are shown in an attribute for all variables.

labels

logical: if TRUE, value labels are shown in an attribute for all variables.

missing

logical: if TRUE, value labels for user-defined missings are shown in an attribute for all variables.

widths

logical: if TRUE, widths are shown in an attribute for all variables.

as.data.frame

logical: if TRUE (default), function returns a regular data frame; if FALSE function returns a tibble.

check

logical: if TRUE (default), argument specification is checked.

Value

Returns a data frame or tibble.

Author(s)

Hadley Wickham, Evan Miller and Danny Smith

References

Wickham H, Miller E, Smith D (2023). haven: Import and Export 'SPSS', 'Stata' and 'SAS' Files. R package version 2.5.3. https://CRAN.R-project.org/package=haven

See Also

read.dta, write.dta, read.xlsx, write.xlsx, read.mplus, write.mplus

Examples

## Not run: 
# Example 1: Read SPSS data file
read.sav("SPSS_Data.sav")
read.sav("SPSS_Data")

# Example 2: Read SPSS data file, convert variables with value labels into factors
read.sav("SPSS_Data.sav", use.value.labels = TRUE)

# Example 3: Read SPSS data file, user-defined missing values are not converted into NAs
read.sav("SPSS_Data.sav", use.missing = FALSE)

# Example 4: Read SPSS data file as tibble
read.sav("SPSS_Data.sav", as.data.frame = FALSE)

## End(Not run)

misty documentation built on June 29, 2024, 9:07 a.m.

Related to read.sav in misty...