Helper function to prepare ADLB for count_abnormal_by_worst_grade()
Source: R/abnormal_by_worst_grade.R
h_adlb_abnormal_by_worst_grade.Rd
Helper function to prepare an ADLB data frame to be used as input in
count_abnormal_by_worst_grade()
. The following pre-processing steps are applied:
adlb
is filtered on variableavisit
to only include post-baseline visits.adlb
is filtered on variablesworst_flag_low
andworst_flag_high
so that only worst grades (in either direction) are included.From the standard lab grade variable
atoxgr
, the following two variables are derived and added toadlb
:
A grade direction variable (e.g.
GRADE_DIR
). The variable takes value"HIGH"
whenatoxgr > 0
,"LOW"
whenatoxgr < 0
, and"ZERO"
otherwise.A toxicity grade variable (e.g.
GRADE_ANL
) where all negative values fromatoxgr
are replaced by their absolute values.
Unused factor levels are dropped from
adlb
viadroplevels()
.
Usage
h_adlb_abnormal_by_worst_grade(
adlb,
atoxgr = "ATOXGR",
avisit = "AVISIT",
worst_flag_low = "WGRLOFL",
worst_flag_high = "WGRHIFL"
)
Arguments
- adlb
(
data.frame
)
ADLB data frame.- atoxgr
(
string
)
name of the analysis toxicity grade variable. This must be afactor
variable.- avisit
(
string
)
name of the analysis visit variable.- worst_flag_low
(
string
)
name of the worst low lab grade flag variable. This variable is set to"Y"
when indicating records of worst low lab grades.- worst_flag_high
(
string
)
name of the worst high lab grade flag variable. This variable is set to"Y"
when indicating records of worst high lab grades.
Value
h_adlb_abnormal_by_worst_grade()
returns the adlb
data frame with two new
variables: GRADE_DIR
and GRADE_ANL
.
Examples
h_adlb_abnormal_by_worst_grade(tern_ex_adlb) %>%
dplyr::select(ATOXGR, GRADE_DIR, GRADE_ANL) %>%
head(10)
#> # A tibble: 10 × 3
#> ATOXGR GRADE_DIR GRADE_ANL
#> <fct> <fct> <fct>
#> 1 -3 LOW 3
#> 2 0 ZERO 0
#> 3 0 ZERO 0
#> 4 2 HIGH 2
#> 5 0 ZERO 0
#> 6 0 ZERO 0
#> 7 -4 LOW 4
#> 8 1 HIGH 1
#> 9 -1 LOW 1
#> 10 0 ZERO 0