Skip to content

Instantly share code, notes, and snippets.

@vanatteveldt
Created January 18, 2024 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanatteveldt/e668a1a698e82802968cbb6c6fdfe01e to your computer and use it in GitHub Desktop.
Save vanatteveldt/e668a1a698e82802968cbb6c6fdfe01e to your computer and use it in GitHub Desktop.
library(tidyverse)
get_label = function(var) tibble(var=var, label=d[[var]] %>% attr(which = "label"))
map(colnames(d), get_label) |> list_rbind()
var = "sex_rec"
get_value_labels <- function(var) {
value_labels <- attr(d[[var]], which="labels")
tibble(var=var, value=value_labels, label=names(value_labels))
}
map(colnames(d), get_value_labels) |> list_rbind()
Extract value labels:
#head(d %>% surveytoolbox::extract_vallab(“vaiablename"),15)
d <- haven::read_sav("data/raw/NLTK23-10_Mariken_wave 1_gedeeld_231018.sav")
View(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment