| get_term_labels {sjlabelled} | R Documentation |
This function retrieves variable labels from model terms. In case of categorical variables, where one variable has multiple dummies, variable name and category value is returned.
get_term_labels(models, mark.cat = FALSE, case = NULL, ...) get_dv_labels(models, case = NULL, ...)
models |
One or more fitted regression models. May also be glm's or
mixed models. Any model with |
mark.cat |
Logical, if |
case |
Desired target case. Labels will automatically converted into the
specified character case. See |
... |
Further arguments passed down to |
Typically, the variable labels from model terms are returned. However,
for categorical terms that have estimates for each category, the
value labels are returned as well. As the return value is a named
vector, you can easily use it with ggplot2's scale_*()
functions to annotate plots.
For get_term_labels(), a (named) character vector with
variable labels of all model terms, which can be used, for instance,
as axis labels to annotate plots.
For get_dv_labels(),
a character vector with variable labels from all dependent variables
of models.
# use data set with labelled data data(efc) fit <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc) get_term_labels(fit) # make "education" categorical library(sjmisc) efc$c172code <- to_factor(efc$c172code) fit <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc) get_term_labels(fit) # get label of dv get_dv_labels(fit) # create "labelled" plot library(ggplot2) library(broom) ggplot(tidy(fit)[-1, ], aes(x = term, y = estimate)) + geom_point() + coord_flip() + scale_x_discrete(labels = get_term_labels(fit))