# add val labs to multiple variables at once
# make a "Likert"-type fake data set to demo
# note, by default, add_val_labs() "vars" arg will do partial matching
# in this case, we catch all vars with "x" in their name
set.seed(272)
dflik <- make_likert_data(scale = 1:7)
vals2label <- 1:7
labs2use <- c(
"VSD",
"SD",
"D",
"N",
"A",
"SA",
"VSA"
)
dflik <- add_val_labs(
data = dflik, vars = c("x", "y3"), # note the vars args
vals = vals2label,
labs = labs2use,
partial = TRUE
)
# note, all "x" vars get the labs, as does "y3"
get_val_lab1(dflik, x1)
get_val_lab1(dflik, x1, simplify = TRUE)
Run the code above in your browser using DataLab