library(tibble)
adqs <- tribble(
~USUBJID, ~PARAMCD, ~AVISITN, ~AVISIT, ~AVAL,
"1", "a", 1, "WEEK 1", 10,
"1", "b", 1, "WEEK 1", 11,
"2", "a", 2, "WEEK 2", 12,
"2", "b", 2, "WEEK 2", 14
)
# Example 1. visit variables are parameter independent
parm_visit_ref <- tribble(
~AVISITN, ~AVISIT,
1, "WEEK 1",
2, "WEEK 2"
)
derive_expected_records(
dataset = adqs,
dataset_ref = parm_visit_ref,
by_vars = exprs(USUBJID, PARAMCD),
set_values_to = exprs(DTYPE = "DERIVED")
)
# Example 2. visit variables are parameter dependent
parm_visit_ref <- tribble(
~PARAMCD, ~AVISITN, ~AVISIT,
"a", 1, "WEEK 1",
"a", 2, "WEEK 2",
"b", 1, "WEEK 1"
)
derive_expected_records(
dataset = adqs,
dataset_ref = parm_visit_ref,
by_vars = exprs(USUBJID, PARAMCD),
set_values_to = exprs(DTYPE = "DERIVED")
)
Run the code above in your browser using DataLab