sjmisc_set_labels: sjmisc 1.8 hack

sjmisc_set_labelsR Documentation

sjmisc 1.8 hack

Description

sjmisc 1.8 hack, value labels

Usage

sjmisc_set_labels(x, labels, force.labels = FALSE, force.values = TRUE)

Note

The usage of the original function is a bit confusing. Here, I summarize:
1) Always use a named vector for valuelabels, in which case force.labels and force.values will be ignored
valuelabels:
1 4 5 9 do not have to all appear in x, that is, you can assign more labels than values (or vice versa, assign less labels)
notice the particular order and symbol: "strongly agree" <- 1
sjmisc_set_labels(x, c("strongly agree"=1,"totally disagree"=4,"refused"=5,"missing"=9))
This format is flipped from the results directly from ez.getlabels

2) when valuelabels="" or NULL, essentially clear value labels attribute

3) if no exisiting attr, using haven style: labels

4) though x could be df, I generally use x as var


jerryzhujian9/ezmisc documentation built on March 9, 2024, 12:44 a.m.