View source: R/summarize_num_patients.R
summarize_num_patients | R Documentation |
Count the number of unique and non-unique patients in a column (variable).
analyze_num_patients(
lyt,
vars,
required = NULL,
count_by = NULL,
unique_count_suffix = TRUE,
na_str = default_na_str(),
nested = TRUE,
.stats = NULL,
.formats = NULL,
.labels = c(unique = "Number of patients with at least one event", nonunique =
"Number of events"),
show_labels = c("default", "visible", "hidden"),
.indent_mods = 0L,
riskdiff = FALSE,
...
)
summarize_num_patients(
lyt,
var,
required = NULL,
count_by = NULL,
unique_count_suffix = TRUE,
na_str = default_na_str(),
.stats = NULL,
.formats = NULL,
.labels = c(unique = "Number of patients with at least one event", nonunique =
"Number of events"),
.indent_mods = 0L,
riskdiff = FALSE,
...
)
s_num_patients(
x,
labelstr,
.N_col,
count_by = NULL,
unique_count_suffix = TRUE
)
s_num_patients_content(
df,
labelstr = "",
.N_col,
.var,
required = NULL,
count_by = NULL,
unique_count_suffix = TRUE
)
lyt |
( |
vars |
( |
required |
( |
count_by |
( |
unique_count_suffix |
( |
na_str |
( |
nested |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
show_labels |
( |
.indent_mods |
(named |
riskdiff |
( |
... |
additional arguments for the lower level functions. |
x |
( |
labelstr |
( |
.N_col |
( |
df |
( |
.var , var |
( |
In general, functions that starts with analyze*
are expected to
work like rtables::analyze()
, while functions that starts with summarize*
are based upon rtables::summarize_row_groups()
. The latter provides a
value for each dividing split in the row and column space, but, being it
bound to the fundamental splits, it is repeated by design in every page
when pagination is involved.
analyze_num_patients()
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_num_patients_content()
to the table layout.
summarize_num_patients()
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_num_patients_content()
to the table layout.
s_num_patients()
returns a named list
of 3 statistics:
unique
: Vector of counts and percentages.
nonunique
: Vector of counts.
unique_count
: Counts.
s_num_patients_content()
returns the same values as s_num_patients()
.
analyze_num_patients()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::analyze()
.
summarize_num_patients()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::summarize_row_groups()
.
s_num_patients()
: Statistics function which counts the number of
unique patients, the corresponding percentage taken with respect to the
total number of patients, and the number of non-unique patients.
s_num_patients_content()
: Statistics function which counts the number of unique patients
in a column (variable), the corresponding percentage taken with respect to the total number of
patients, and the number of non-unique patients in the column.
As opposed to summarize_num_patients()
, this function does not repeat the produced rows.
df <- data.frame(
USUBJID = as.character(c(1, 2, 1, 4, NA, 6, 6, 8, 9)),
ARM = c("A", "A", "A", "A", "A", "B", "B", "B", "B"),
AGE = c(10, 15, 10, 17, 8, 11, 11, 19, 17)
)
tbl <- basic_table() %>%
split_cols_by("ARM") %>%
add_colcounts() %>%
analyze_num_patients("USUBJID", .stats = c("unique")) %>%
build_table(df)
tbl
# Use the statistics function to count number of unique and nonunique patients.
s_num_patients(x = as.character(c(1, 1, 1, 2, 4, NA)), labelstr = "", .N_col = 6L)
s_num_patients(
x = as.character(c(1, 1, 1, 2, 4, NA)),
labelstr = "",
.N_col = 6L,
count_by = c(1, 1, 2, 1, 1, 1)
)
# Count number of unique and non-unique patients.
df <- data.frame(
USUBJID = as.character(c(1, 2, 1, 4, NA)),
EVENT = as.character(c(10, 15, 10, 17, 8))
)
s_num_patients_content(df, .N_col = 5, .var = "USUBJID")
df_by_event <- data.frame(
USUBJID = as.character(c(1, 2, 1, 4, NA)),
EVENT = c(10, 15, 10, 17, 8)
)
s_num_patients_content(df_by_event, .N_col = 5, .var = "USUBJID", count_by = "EVENT")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.