Assign values to a related variable within a domain

rel_var(df = NULL, var_name = NULL, var_values = NULL, related_var = NULL)

Arguments

df

data frame containing the related variables.

var_name

related to variable name.

var_values

values of related to variable.

related_var

variable name with existing values to which var_name values must relate.

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
  )
)
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"