Set variable labels
Usage
set_labels(data, labels = list(), ...)
set_labels(data, ...) <- value
Arguments
- data
data.frame
ortibble
- labels, value
either a named
list
orcharacter
vector, arequirements
object, or a data frame with labelled variables. Additionally,NULL
can be used to remove variable labels.- ...
named pairs where the name corresponds to one variable in
data
and the value is either the variable label or a source to inherit the label from. This label is kept over an element inlabels
.
Value
object with the same structure as data
with label attributes
assigned to the variables provided in labels
and ...
.
Examples
# remove all variable labels for examples
pk_no_labels <- dmcognigen_pk |>
set_labels(NULL)
# with a requirements object
pk_with_labels <- pk_no_labels |>
set_labels(dmcognigen_pk_requirements)
#> ℹ Inheriting labels from `dmcognigen_pk_requirements` <requirements> object.
# with another data set
pk_with_labels <- pk_no_labels |>
set_labels(dmcognigen_pk)
#> ℹ Inheriting labels from variables in `dmcognigen_pk` <data.frame>.
# by providing individual variable labels with `...`
pk_with_labels <- pk_no_labels |>
set_labels(ID = "ID")
# or any combination
pk_with_labels <- pk_no_labels |>
set_labels(dmcognigen_pk_requirements, USUBJID = dmcognigen_cov, ID = "ID")
#> ℹ Inheriting labels from `dmcognigen_pk_requirements` <requirements> object.
#> ℹ Inheriting labels from variables in `dmcognigen_cov` <data.frame>.
# apply labels from multiple datasets by using the function multiple times
pk_with_labels <- pk_no_labels |>
set_labels(dmcognigen_cov) |>
set_labels(dmcognigen_dose) |>
set_labels(dmcognigen_conc)
#> ℹ Inheriting labels from variables in `dmcognigen_cov` <data.frame>.
#> ℹ Inheriting labels from variables in `dmcognigen_dose` <data.frame>.
#> ℹ Inheriting labels from variables in `dmcognigen_conc` <data.frame>.