Skip to content

Instantly share code, notes, and snippets.

@JosiahParry
Created November 30, 2019 15:22
Show Gist options
  • Save JosiahParry/36316c2614110049d514f1ecf2ef7184 to your computer and use it in GitHub Desktop.
Save JosiahParry/36316c2614110049d514f1ecf2ef7184 to your computer and use it in GitHub Desktop.
Useful quick tricks I learned to deal with the hell that is SPSS .sav data format
# read in sav file
noise <- haven::read_sav("http://staff.bath.ac.uk/pssiw/stats2/noisedata.sav")
# convert coded response to response text
haven::as_factor(noise)
# read in sav file with column labels
personality <- haven::read_sav("http://staff.bath.ac.uk/pssiw/stats2/personality.sav")
# generate a get_label f(x) via purr
get_label <- purrr::attr_getter("label")
# use get_label to retrieve column labels
map_chr(personality, get_label)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment