Description Usage Arguments Details Value Examples

View source: R/get_model_labels.R

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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
term_labels(
models,
mark.cat = FALSE,
case = NULL,
prefix = c("none", "varname", "label"),
...
)
get_term_labels(
models,
mark.cat = FALSE,
case = NULL,
prefix = c("none", "varname", "label"),
...
)
response_labels(models, case = NULL, multi.resp = FALSE, mv = FALSE, ...)
get_dv_labels(models, case = NULL, multi.resp = FALSE, mv = FALSE, ...)
``` |

`models` |
One or more fitted regression models. May also be glm's or mixed models. |

`mark.cat` |
Logical, if |

`case` |
Desired target case. Labels will automatically converted into the
specified character case. See |

`prefix` |
Indicates whether the value labels of categorical variables should be prefixed, e.g. with the variable name or variable label. May be abbreviated. See 'Examples', |

`...` |
Further arguments passed down to |

`mv, multi.resp` |
Logical, if |

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 `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 `response_labels()`

,
a character vector with variable labels from all dependent variables
of `models`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
# use data set with labelled data
data(efc)
fit <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)
term_labels(fit)
# make "education" categorical
if (require("sjmisc")) {
efc$c172code <- to_factor(efc$c172code)
fit <- lm(barthtot ~ c160age + c12hour + c161sex + c172code, data = efc)
term_labels(fit)
# prefix value of categorical variables with variable name
term_labels(fit, prefix = "varname")
# prefix value of categorical variables with value label
term_labels(fit, prefix = "label")
# get label of dv
response_labels(fit)
}
``` |

```
c160age
"carer' age"
c12hour
"average number of hours of care per week"
c161sex
"carer's gender"
c172code
"carer's level of education"
Loading required package: sjmisc
Attaching package: ‘sjmisc’
The following objects are masked from ‘package:sjlabelled’:
to_character, to_factor, to_label, to_numeric
[1] "Total score BARTHEL INDEX"
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.