Count number of patients with missed doses by thresholds
Source:R/count_missed_doses.R
count_missed_doses.Rd
The analyze function creates a layout element to calculate cumulative counts of patients with number of missed doses at least equal to user-specified threshold values.
This function analyzes numeric variable vars
, a variable with numbers of missed doses,
against the threshold values supplied to the thresholds
argument as a numeric vector. This function
assumes that every row of the given data frame corresponds to a unique patient.
Usage
count_missed_doses(
lyt,
vars,
thresholds,
var_labels = vars,
show_labels = "visible",
na_str = default_na_str(),
nested = TRUE,
...,
table_names = vars,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_count_nonmissing(x)
s_count_missed_doses(
x,
thresholds,
.N_col,
.N_row,
denom = c("N_col", "n", "N_row")
)
a_count_missed_doses(
x,
thresholds,
.N_col,
.N_row,
denom = c("N_col", "n", "N_row")
)
Arguments
- lyt
(
PreDataTableLayouts
)
layout that analyses will be added to.- vars
(
character
)
variable names for the primary analysis variable to be iterated over.- thresholds
(
numeric
)
minimum number of missed doses the patients had.- var_labels
(
character
)
variable labels.- show_labels
(
string
)
label visibility: one of "default", "visible" and "hidden".- 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.Options are:
'n', 'count_fraction', 'count_fraction_fixed_dp'
- .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.- x
(
numeric
)
vector of numbers we want to analyze.- .N_col
(
integer(1)
)
column-wise N (column count) for the full column being analyzed that is typically passed byrtables
.- .N_row
(
integer(1)
)
row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is typically passed byrtables
.- denom
-
(
string
)
choice of denominator for proportion. Options are:n
: number of values in this row and column intersection.N_row
: total number of values in this row across columns.N_col
: total number of values in this column across rows.
Value
count_missed_doses()
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_missed_doses()
to the table layout.
s_count_nonmissing()
returns the statisticn
which is the count of non-missing values inx
.
s_count_missed_doses()
returns the statisticsn
andcount_fraction
with one element for each threshold.
a_count_missed_doses()
returns the corresponding list with formattedrtables::CellValue()
.
Functions
count_missed_doses()
: Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()
.s_count_nonmissing()
: Statistics function to count non-missing values.s_count_missed_doses()
: Statistics function to count patients with missed doses.a_count_missed_doses()
: Formatted analysis function which is used asafun
incount_missed_doses()
.
See also
Relevant description function
d_count_missed_doses()
which generates labels forcount_missed_doses()
.Similar analyze function
count_cumulative()
which more generally counts cumulative values and has more options for threshold handling, but uses different labels.
Examples
library(dplyr)
anl <- tern_ex_adsl %>%
distinct(STUDYID, USUBJID, ARM) %>%
mutate(
PARAMCD = "TNDOSMIS",
PARAM = "Total number of missed doses during study",
AVAL = sample(0:20, size = nrow(tern_ex_adsl), replace = TRUE),
AVALC = ""
)
basic_table() %>%
split_cols_by("ARM") %>%
add_colcounts() %>%
count_missed_doses("AVAL", thresholds = c(1, 5, 10, 15), var_labels = "Missed Doses") %>%
build_table(anl, alt_counts_df = tern_ex_adsl)
#> A: Drug X B: Placebo C: Combination
#> (N=69) (N=73) (N=58)
#> —————————————————————————————————————————————————————————————————————
#> Missed Doses
#> n 69 73 58
#> At least 1 missed dose 69 (100%) 69 (94.5%) 55 (94.8%)
#> At least 5 missed doses 57 (82.6%) 55 (75.3%) 50 (86.2%)
#> At least 10 missed doses 40 (58%) 40 (54.8%) 32 (55.2%)
#> At least 15 missed doses 26 (37.7%) 25 (34.2%) 13 (22.4%)