get_spss_label: Get SPSS label

Description Usage Arguments Value Examples

View source: R/get_spss_label.R

Description

Returns variable labels from an SPSS dataset read in with either the foreign or haven packages.

Usage

1
get_spss_label(df, var, null_label = "No label found", unlist = TRUE)

Arguments

df

An SPSS dataset originally read into R via either foreign or haven.

var

character vector containing the names of variables whose labels should be returned.

null_label

character value to return if there is no label for a variable. Defaults to "No label found".

unlist

Should the output be converted from a list to a vector? Defaults to TRUE. Set to FALSE to return a list instead.

Value

The SPSS label/s, as a vector or a list.

Examples

1
2
3
4
get_spss_label(dec13_excerpt, "q1")
get_spss_label(dec13_excerpt, c("q1", "party"))
get_spss_label(dec13_excerpt, c("q1", "sdfklsdf", "party"), null_label = "here be dragons")
get_spss_label(dec13_excerpt, c("q1", "sdfklsdf", "party"), unlist = FALSE)

pewresearch/pewmethods documentation built on March 27, 2020, 7:22 p.m.