library(tibble)
# Example 1: Derive BSA where height is measured only once using constant_by_vars
advs <- tibble::tribble(
~USUBJID, ~PARAMCD, ~PARAM, ~AVAL, ~VISIT,
"01-701-1015", "HEIGHT", "Height (cm)", 170, "BASELINE",
"01-701-1015", "WEIGHT", "Weight (kg)", 75, "BASELINE",
"01-701-1015", "WEIGHT", "Weight (kg)", 78, "MONTH 1",
"01-701-1015", "WEIGHT", "Weight (kg)", 80, "MONTH 2",
"01-701-1028", "HEIGHT", "Height (cm)", 185, "BASELINE",
"01-701-1028", "WEIGHT", "Weight (kg)", 90, "BASELINE",
"01-701-1028", "WEIGHT", "Weight (kg)", 88, "MONTH 1",
"01-701-1028", "WEIGHT", "Weight (kg)", 85, "MONTH 2",
)
derive_param_bsa(
advs,
by_vars = exprs(USUBJID, VISIT),
method = "Mosteller",
set_values_to = exprs(
PARAMCD = "BSA",
PARAM = "Body Surface Area (m^2)"
),
get_unit_expr = extract_unit(PARAM),
constant_by_vars = exprs(USUBJID)
)
derive_param_bsa(
advs,
by_vars = exprs(USUBJID, VISIT),
method = "Fujimoto",
set_values_to = exprs(
PARAMCD = "BSA",
PARAM = "Body Surface Area (m^2)"
),
get_unit_expr = extract_unit(PARAM),
constant_by_vars = exprs(USUBJID)
)
# Example 2: Derive BSA where height is measured only once and keep only one record
# where both height and weight are measured.
derive_param_bsa(
advs,
by_vars = exprs(USUBJID, VISIT),
method = "Mosteller",
set_values_to = exprs(
PARAMCD = "BSA",
PARAM = "Body Surface Area (m^2)"
),
get_unit_expr = extract_unit(PARAM)
)
# Example 3: Pediatric study where height and weight are measured multiple times
advs <- tibble::tribble(
~USUBJID, ~PARAMCD, ~PARAM, ~AVAL, ~VISIT,
"01-101-1001", "HEIGHT", "Height (cm)", 47.1, "BASELINE",
"01-101-1001", "HEIGHT", "Height (cm)", 59.1, "WEEK 12",
"01-101-1001", "HEIGHT", "Height (cm)", 64.7, "WEEK 24",
"01-101-1001", "HEIGHT", "Height (cm)", 68.2, "WEEK 48",
"01-101-1001", "WEIGHT", "Weight (kg)", 2.6, "BASELINE",
"01-101-1001", "WEIGHT", "Weight (kg)", 5.3, "WEEK 12",
"01-101-1001", "WEIGHT", "Weight (kg)", 6.7, "WEEK 24",
"01-101-1001", "WEIGHT", "Weight (kg)", 7.4, "WEEK 48",
)
derive_param_bsa(
advs,
by_vars = exprs(USUBJID, VISIT),
method = "Mosteller",
set_values_to = exprs(
PARAMCD = "BSA",
PARAM = "Body Surface Area (m^2)"
),
get_unit_expr = extract_unit(PARAM)
)
Run the code above in your browser using DataLab