library(tibble)
adcvrisk <- tribble(
~USUBJID, ~PARAMCD, ~PARAM, ~AVAL, ~AVALU,
~VISIT, ~AGE, ~SEX, ~SMOKEFL, ~DIABETFL, ~TRTHYPFL,
"01-701-1015", "SYSBP", "Systolic Blood Pressure (mmHg)", 121,
"mmHg", "BASELINE", 44, "F", "N", "N", "N",
"01-701-1015", "SYSBP", "Systolic Blood Pressure (mmHg)", 115,
"mmHg", "WEEK 2", 44, "F", "N", "N", "Y",
"01-701-1015", "CHOL", "Total Cholesterol (mg/dL)", 216.16,
"mg/dL", "BASELINE", 44, "F", "N", "N", "N",
"01-701-1015", "CHOL", "Total Cholesterol (mg/dL)", 210.78,
"mg/dL", "WEEK 2", 44, "F", "N", "N", "Y",
"01-701-1015", "CHOLHDL", "Cholesterol/HDL-Cholesterol (mg/dL)", 54.91,
"mg/dL", "BASELINE", 44, "F", "N", "N", "N",
"01-701-1015", "CHOLHDL", "Cholesterol/HDL-Cholesterol (mg/dL)", 26.72,
"mg/dL", "WEEK 2", 44, "F", "N", "N", "Y",
"01-701-1028", "SYSBP", "Systolic Blood Pressure (mmHg)", 119,
"mmHg", "BASELINE", 55, "M", "Y", "Y", "Y",
"01-701-1028", "SYSBP", "Systolic Blood Pressure (mmHg)", 101,
"mmHg", "WEEK 2", 55, "M", "Y", "Y", "Y",
"01-701-1028", "CHOL", "Total Cholesterol (mg/dL)", 292.01,
"mg/dL", "BASELINE", 55, "M", "Y", "Y", "Y",
"01-701-1028", "CHOL", "Total Cholesterol (mg/dL)", 246.73,
"mg/dL", "WEEK 2", 55, "M", "Y", "Y", "Y",
"01-701-1028", "CHOLHDL", "Cholesterol/HDL-Cholesterol (mg/dL)", 65.55,
"mg/dL", "BASELINE", 55, "M", "Y", "Y", "Y",
"01-701-1028", "CHOLHDL", "Cholesterol/HDL-Cholesterol (mg/dL)", 44.62,
"mg/dL", "WEEK 2", 55, "M", "Y", "Y", "Y"
)
adcvrisk %>%
derive_param_framingham(
by_vars = exprs(USUBJID, VISIT),
set_values_to = exprs(
PARAMCD = "FCVD101",
PARAM = "FCVD1-Framingham CVD 10-Year Risk Score (%)"
),
get_unit_expr = AVALU
)
derive_param_framingham(
adcvrisk,
by_vars = exprs(USUBJID, VISIT),
set_values_to = exprs(
PARAMCD = "FCVD101",
PARAM = "FCVD1-Framingham CVD 10-Year Risk Score (%)"
),
get_unit_expr = extract_unit(PARAM)
)
Run the code above in your browser using DataLab