sjmisc_set_labels | R Documentation |
sjmisc 1.8 hack, value labels
sjmisc_set_labels(x, labels, force.labels = FALSE, force.values = TRUE)
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.