get_labels {hesim} | R Documentation |
Get value labels
Description
Get value labels for the ID variables in a hesim_data
object and create a list
of named vectors that can be passed to formatting and plotting functions. This
lets users create nice labels for treatment strategies, subgroups, health states,
and/or transitions when presenting results.
Usage
get_labels(
object,
strategy = "strategy_name",
grp = "grp_name",
state = "state_name",
transition = "transition_name",
death_label = "Death"
)
Arguments
object |
An object of class |
strategy |
The name of the column in the |
grp |
The name of the column in the |
state |
The name of the column in the |
transition |
The name of the column in the |
death_label |
The label to use for the death health state. By default a
label named "Death" will be concatenated to the labels for the non-death health
states. The death state can be omitted from labels for the health states by setting
|
Value
A list of named vectors containing the values and labels of variables. The elements of each vector are the values of a variable and the names are the labels. The names of the list are the names of the ID variables.
See Also
Examples
library("data.table")
strategies <- data.table(
strategy_id = c(1, 2),
strategy_name = c("Strategy 1", "Strategy 2")
)
patients <- data.table(
patient_id = seq(1, 4),
age = c(50, 55, 60, 65),
grp_id = c(1, 1, 2, 2),
grp_name = rep(c("Age 50-59", "Age 60-69"), each = 2)
)
states <- data.table(
state_id = seq(1, 2),
state_name = c("State 1", "State 2")
)
hesim_dat <- hesim_data(
strategies = strategies,
patients = patients,
states = states
)
labs <- get_labels(hesim_dat)
labs
# Pass to set_labels()
d <- data.table(strategy_id = c(1, 1, 2, 2),
grp_id = c(1, 2, 1, 2))
set_labels(d, labs, new_name = c("strategy_name", "grp_name"))
d