Patient counts for laboratory events (worsen from baseline) by highest grade post-baseline
Source:R/abnormal_by_worst_grade_worsen.R
abnormal_by_worst_grade_worsen.Rd
Usage
count_abnormal_lab_worsen_by_baseline(
lyt,
var,
variables = list(id = "USUBJID", baseline_var = "BTOXGR", direction_var = "GRADDR"),
na_str = default_na_str(),
nested = TRUE,
...,
table_names = NULL,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_count_abnormal_lab_worsen_by_baseline(
df,
.var = "ATOXGR",
variables = list(id = "USUBJID", baseline_var = "BTOXGR", direction_var = "GRADDR")
)
a_count_abnormal_lab_worsen_by_baseline(
df,
.var = "ATOXGR",
variables = list(id = "USUBJID", baseline_var = "BTOXGR", direction_var = "GRADDR")
)
Arguments
- lyt
(
PreDataTableLayouts
)
layout that analyses will be added to.- variables
-
(named
list
ofstring
)
list of additional analysis variables including:id
(string
)
subject variable name.baseline_var
(string
)
name of the data column containing baseline toxicity variable.direction_var
(string
)
seedirection_var
for more details.
- na_str
(
string
)
string used to replace allNA
or empty values in the output.- nested
(
flag
)
whether this layout instruction should be applied within the existing layout structure _if possible (TRUE
, the default) or as a new top-level element (FALSE
). Ignored if it would nest a split. underneath analyses, which is not allowed.- ...
additional arguments for the lower level functions.
- table_names
(
character
)
this can be customized in the case that the samevars
are analyzed multiple times, to avoid warnings fromrtables
.- .stats
(
character
)
statistics to select for the table. Runget_stats("abnormal_by_worst_grade_worsen")
to see all available statistics.- .formats
(named
character
orlist
)
formats for the statistics. See Details inanalyze_vars
for more information on the"auto"
setting.- .labels
(named
character
)
labels for the statistics (without indent).- .indent_mods
(named
integer
)
indent modifiers for the labels. Defaults to 0, which corresponds to the unmodified default behavior. Can be negative.- df
(
data.frame
)
data set containing all analysis variables.- .var, var
(
string
)
single variable name that is passed byrtables
when requested by a statistics function.
Value
count_abnormal_lab_worsen_by_baseline()
returns a layout object suitable for passing to further layouting functions, or tortables::build_table()
. Adding this function to anrtable
layout will add formatted rows containing the statistics froms_count_abnormal_lab_worsen_by_baseline()
to the table layout.
s_count_abnormal_lab_worsen_by_baseline()
returns 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".
a_count_abnormal_lab_worsen_by_baseline()
returns the corresponding list with formattedrtables::CellValue()
.
Functions
count_abnormal_lab_worsen_by_baseline()
: Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()
.s_count_abnormal_lab_worsen_by_baseline()
: Statistics function for patients whose worst post-baseline lab grades are worse than their baseline grades.a_count_abnormal_lab_worsen_by_baseline()
: Formatted analysis function which is used asafun
incount_abnormal_lab_worsen_by_baseline()
.
See also
Relevant helper functions h_adlb_worsen()
and h_worsen_counter()
Examples
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"
)
basic_table() %>%
split_cols_by("ARMCD") %>%
add_colcounts() %>%
split_rows_by("PARAMCD") %>%
split_rows_by("GRADDR") %>%
count_abnormal_lab_worsen_by_baseline(
var = "ATOXGR",
variables = list(
id = "USUBJID",
baseline_var = "BTOXGR",
direction_var = "GRADDR"
)
) %>%
append_topleft("Direction of Abnormality") %>%
build_table(df = df, alt_counts_df = tern_ex_adsl)
#> ARM A ARM B ARM C
#> Direction of Abnormality (N=69) (N=73) (N=58)
#> ————————————————————————————————————————————————————————————————————————
#> IGA
#> High
#> 1 6/63 (9.5%) 6/64 (9.4%) 4/50 (8%)
#> 2 8/64 (12.5%) 5/67 (7.5%) 8/53 (15.1%)
#> 3 7/66 (10.6%) 5/68 (7.4%) 9/57 (15.8%)
#> 4 6/68 (8.8%) 2/72 (2.8%) 3/58 (5.2%)
#> Any 27/68 (39.7%) 18/72 (25%) 24/58 (41.4%)
#> ALT
#> High
#> 1 7/63 (11.1%) 6/62 (9.7%) 2/48 (4.2%)
#> 2 12/63 (19%) 4/67 (6%) 11/50 (22%)
#> 3 4/65 (6.2%) 11/71 (15.5%) 7/56 (12.5%)
#> 4 1/67 (1.5%) 8/71 (11.3%) 4/57 (7%)
#> Any 24/67 (35.8%) 29/71 (40.8%) 24/57 (42.1%)
#> Low
#> 1 12/67 (17.9%) 4/66 (6.1%) 7/52 (13.5%)
#> 2 9/68 (13.2%) 12/69 (17.4%) 6/55 (10.9%)
#> 3 6/69 (8.7%) 4/71 (5.6%) 5/56 (8.9%)
#> 4 7/69 (10.1%) 7/73 (9.6%) 6/58 (10.3%)
#> Any 34/69 (49.3%) 27/73 (37%) 24/58 (41.4%)
#> CRP
#> Low
#> 1 11/66 (16.7%) 10/67 (14.9%) 4/47 (8.5%)
#> 2 8/66 (12.1%) 1/70 (1.4%) 6/50 (12%)
#> 3 4/68 (5.9%) 9/70 (12.9%) 5/53 (9.4%)
#> 4 7/69 (10.1%) 6/72 (8.3%) 4/55 (7.3%)
#> Any 30/69 (43.5%) 26/72 (36.1%) 19/55 (34.5%)