
s_count_abnormal_lab_worsen_by_baseline()
Helper function to count the number of patients and the fraction of patients according to
highest post-baseline lab grade variable .var
, baseline lab grade variable baseline_var
,
and the direction of interest specified in direction_var
.
h_worsen_counter(df, id, .var, baseline_var, direction_var)
The counts and fraction of patients whose worst post-baseline lab grades are worse than their baseline grades, for post-baseline worst grades "1", "2", "3", "4" and "Any".
(data.frame
)
data set containing all analysis variables.
(string
)
subject variable name.
(string
)
single variable name that is passed by rtables
when requested
by a statistics function.
(string
)
name of the baseline lab grade variable.
(string
)
name of the direction variable specifying the direction of the shift table of
interest. Only lab records flagged by L
, H
or B
are included in the shift table.
L
: low direction only
H
: high direction only
B
: both low and high directions
abnormal_lab_worsen_by_baseline
library(dplyr)
# The direction variable, GRADDR, is based on metadata
adlb <- tern_ex_adlb %>%
mutate(
GRADDR = case_when(
PARAMCD == "ALT" ~ "B",
PARAMCD == "CRP" ~ "L",
PARAMCD == "IGA" ~ "H"
)
) %>%
filter(SAFFL == "Y" & ONTRTFL == "Y" & GRADDR != "")
df <- h_adlb_worsen(
adlb,
worst_flag_low = c("WGRLOFL" = "Y"),
worst_flag_high = c("WGRHIFL" = "Y"),
direction_var = "GRADDR"
)
# `h_worsen_counter`
h_worsen_counter(
df %>% filter(PARAMCD == "CRP" & GRADDR == "Low"),
id = "USUBJID",
.var = "ATOXGR",
baseline_var = "BTOXGR",
direction_var = "GRADDR"
)
Run the code above in your browser using DataLab