View source: R/abnormal_by_worst_grade_worsen.R
h_worsen_counter | R Documentation |
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)
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".
abnormal_by_worst_grade_worsen
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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.