rel_var {random.cdisc.data} | R Documentation |
Related Variables: Assign
Description
Assign values to a related variable within a domain.
Usage
rel_var(df, var_name, related_var, var_values = NULL)
Arguments
df |
( |
var_name |
( |
related_var |
( |
var_values |
( |
Value
df
with added factor variable var_name
containing var_values
corresponding to related_var
.
Examples
# Example with data.frame.
params <- c("Level A", "Level B", "Level C")
adlb_df <- data.frame(
ID = 1:9,
PARAM = factor(
rep(c("Level A", "Level B", "Level C"), 3),
levels = params
)
)
rel_var(
df = adlb_df,
var_name = "PARAMCD",
var_values = c("A", "B", "C"),
related_var = "PARAM"
)
# Example with tibble.
adlb_tbl <- tibble::tibble(
ID = 1:9,
PARAM = factor(
rep(c("Level A", "Level B", "Level C"), 3),
levels = params
)
)
rel_var(
df = adlb_tbl,
var_name = "PARAMCD",
var_values = c("A", "B", "C"),
related_var = "PARAM"
)
[Package random.cdisc.data version 0.3.15 Index]