Skip to contents

In many situations it can be useful to have the ability to replace the uninformative variable names (colnames) from a SPSS matrix (e.g. SD02, SD08_02) with their respective label attribute (e.g., "Gender/Sex" or "Age 15-25"). This function utilizes the utility function clean_names to convert the labels from SPSS to proper variable names (e.g.,"gender_sex" or "age_15_25") and sets them as new column names

Usage

spss_swap(
  df,
  repl_umlaut = TRUE,
  old_itemnames = c("remove", "prepend", "append")
)

Arguments

df

tibble read in the read_sav from haven

repl_umlaut

Default is TRUE. If provided True it replaces umlauts (vowel mutations) like ä, ö, ü and ß with respective ae, oe, ue, and ss

old_itemnames

Options are "prepend", "append" or, "remove". Default is "prepend" With "prepend" the new item names will be prepended by the old item names. E.g., the old item name was "q0003" and the description "Gender" the new item name will be "q0003_gender"

Value

A tibble with more human readable names (old labels as names)

Author

Friedrich-Samuel Taubitz & Bjoern Buedenbender

Examples

if (FALSE) {
datscience::spss_swap(df_sav)
}