View source: R/count_patients_with_event.R
count_patients_with_event | R Documentation |
The analyze function count_patients_with_event()
creates a layout element to calculate patient counts for a
user-specified set of events.
This function analyzes primary analysis variable vars
which indicates unique subject identifiers. Events
are defined by the user as a named vector via the filters
argument, where each name corresponds to a
variable and each value is the value(s) that that variable takes for the event.
If there are multiple records with the same event recorded for a patient, only one occurrence is counted.
count_patients_with_event(
lyt,
vars,
filters,
riskdiff = FALSE,
na_str = default_na_str(),
nested = TRUE,
...,
table_names = vars,
.stats = "count_fraction",
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_count_patients_with_event(
df,
.var,
filters,
.N_col,
.N_row,
denom = c("n", "N_row", "N_col")
)
a_count_patients_with_event(
df,
.var,
filters,
.N_col,
.N_row,
denom = c("n", "N_row", "N_col")
)
lyt |
( |
vars |
( |
filters |
( |
riskdiff |
( |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var |
( |
.N_col |
( |
.N_row |
( |
denom |
(
|
count_patients_with_event()
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 rows containing
the statistics from s_count_patients_with_event()
to the table layout.
s_count_patients_with_event()
returns the count and fraction of unique identifiers with the defined event.
a_count_patients_with_event()
returns the corresponding list with formatted rtables::CellValue()
.
count_patients_with_event()
: Layout-creating function which can take statistics function
arguments and additional format arguments. This function is a wrapper for rtables::analyze()
.
s_count_patients_with_event()
: Statistics function which counts the number of patients for which
the defined event has occurred.
a_count_patients_with_event()
: Formatted analysis function which is used as afun
in count_patients_with_event()
.
count_patients_with_flags
# `count_patients_with_event()`
lyt <- basic_table() %>%
split_cols_by("ARM") %>%
add_colcounts() %>%
count_values(
"STUDYID",
values = "AB12345",
.stats = "count",
.labels = c(count = "Total AEs")
) %>%
count_patients_with_event(
"SUBJID",
filters = c("TRTEMFL" = "Y"),
.labels = c(count_fraction = "Total number of patients with at least one adverse event"),
table_names = "tbl_all"
) %>%
count_patients_with_event(
"SUBJID",
filters = c("TRTEMFL" = "Y", "AEOUT" = "FATAL"),
.labels = c(count_fraction = "Total number of patients with fatal AEs"),
table_names = "tbl_fatal"
) %>%
count_patients_with_event(
"SUBJID",
filters = c("TRTEMFL" = "Y", "AEOUT" = "FATAL", "AEREL" = "Y"),
.labels = c(count_fraction = "Total number of patients with related fatal AEs"),
.indent_mods = c(count_fraction = 2L),
table_names = "tbl_rel_fatal"
)
build_table(lyt, tern_ex_adae, alt_counts_df = tern_ex_adsl)
# `s_count_patients_with_event()`
s_count_patients_with_event(
tern_ex_adae,
.var = "SUBJID",
filters = c("TRTEMFL" = "Y")
)
s_count_patients_with_event(
tern_ex_adae,
.var = "SUBJID",
filters = c("TRTEMFL" = "Y", "AEOUT" = "FATAL")
)
s_count_patients_with_event(
tern_ex_adae,
.var = "SUBJID",
filters = c("TRTEMFL" = "Y", "AEOUT" = "FATAL"),
denom = "N_col",
.N_col = 456
)
# `a_count_patients_with_event()`
a_count_patients_with_event(
tern_ex_adae,
.var = "SUBJID",
filters = c("TRTEMFL" = "Y"),
.N_col = 100,
.N_row = 100
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.