rel_var.Rd
Assign values to a related variable within a domain
rel_var(df = NULL, var_name = NULL, var_values = NULL, related_var = NULL)
data frame containing the related variables.
related to variable name.
values of related to variable.
variable name with existing values to which var_name values must relate.
# 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
)
)
random.cdisc.data:::rel_var(
df = ADLB_df,
var_name = "PARAMCD",
var_values = c("A", "B", "C"),
related_var = "PARAM"
)
#> [1] "A" "B" "C" "A" "B" "C" "A" "B" "C"
# Example with tibble.
ADLB_tbl <- tibble::tibble(
ID = 1:9,
PARAM = factor(
rep(c("Level A", "Level B", "Level C"), 3),
levels = params
)
)
random.cdisc.data:::rel_var(
df = ADLB_tbl,
var_name = "PARAMCD",
var_values = c("A", "B", "C"),
related_var = "PARAM"
)
#> [1] "A" "B" "C" "A" "B" "C" "A" "B" "C"