count_patients_events_in_cols | R Documentation |
Counting the number of unique patients and the total number of all and specific events when a column table layout is required.
summarize_patients_events_in_cols(
lyt,
id = "USUBJID",
filters_list = list(),
empty_stats = character(),
na_str = default_na_str(),
...,
.stats = c("unique", "all", names(filters_list)),
.labels = c(unique = "Patients (All)", all = "Events (All)",
labels_or_names(filters_list)),
col_split = TRUE
)
s_count_patients_and_multiple_events(
df,
id,
filters_list,
empty_stats = character(),
labelstr = "",
custom_label = NULL
)
lyt |
( |
id |
( |
filters_list |
(named |
empty_stats |
( |
na_str |
( |
... |
additional arguments for the lower level functions. |
.stats |
( |
.labels |
(named |
col_split |
( |
df |
( |
labelstr |
( |
custom_label |
( |
summarize_patients_events_in_cols()
returns a layout object suitable for passing to further layouting functions,
or to rtables::build_table()
. Adding this function to an rtable
layout will add formatted content rows
containing the statistics from s_count_patients_and_multiple_events()
to the table layout.
s_count_patients_and_multiple_events()
returns a list with the statistics:
unique
: number of unique patients in df
.
all
: number of rows in df
.
one element with the same name as in filters_list
: number of rows in df
,
i.e. events, fulfilling the filter condition.
summarize_patients_events_in_cols()
: Layout-creating function which can take statistics function
arguments and additional format arguments. This function is a wrapper for rtables::summarize_row_groups()
.
s_count_patients_and_multiple_events()
: Statistics function which counts numbers of patients and multiple
events defined by filters. Used as analysis function afun
in summarize_patients_events_in_cols()
.
df <- data.frame(
USUBJID = rep(c("id1", "id2", "id3", "id4"), c(2, 3, 1, 1)),
ARM = c("A", "A", "B", "B", "B", "B", "A"),
AESER = rep("Y", 7),
AESDTH = c("Y", "Y", "N", "Y", "Y", "N", "N"),
AEREL = c("Y", "Y", "N", "Y", "Y", "N", "Y"),
AEDECOD = c("A", "A", "A", "B", "B", "C", "D"),
AEBODSYS = rep(c("SOC1", "SOC2", "SOC3"), c(3, 3, 1))
)
# `summarize_patients_events_in_cols()`
basic_table() %>%
summarize_patients_events_in_cols(
filters_list = list(
related = formatters::with_label(c(AEREL = "Y"), "Events (Related)"),
fatal = c(AESDTH = "Y"),
fatal_related = c(AEREL = "Y", AESDTH = "Y")
),
custom_label = "%s Total number of patients and events"
) %>%
build_table(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.