Skip to contents

[Stable]

These are specific functions to count patients with missed doses. The difference to count_cumulative() is mainly the special labels.

Usage

s_count_nonmissing(x)

s_count_missed_doses(x, thresholds, .N_col)

a_count_missed_doses(x, thresholds, .N_col)

count_missed_doses(
  lyt,
  vars,
  var_labels = vars,
  show_labels = "visible",
  ...,
  table_names = vars,
  .stats = NULL,
  .formats = NULL,
  .labels = NULL,
  .indent_mods = NULL
)

Arguments

x

(numeric)
vector of numbers we want to analyze.

thresholds

(vector of count)
number of missed doses the patients at least had.

.N_col

(count)
row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is passed by rtables.

lyt

(layout)
input layout where analyses will be added to.

vars

(character)
variable names for the primary analysis variable to be iterated over.

var_labels

character for label.

show_labels

label visibility: one of "default", "visible" and "hidden".

...

additional arguments for the lower level functions.

table_names

(character)
this can be customized in case that the same vars are analyzed multiple times, to avoid warnings from rtables.

.stats

(character)
statistics to select for the table.

.formats

(named character or list)
formats for the statistics.

.labels

(named character)
labels for the statistics (without indent).

.indent_mods

(named integer)
indent modifiers for the labels.

Value

s_count_nonmissing() returns the statistic n which is the count of non-missing values in x.

s_count_missed_doses() returns the statistics n and count_fraction with one element for each threshold.

Functions

  • s_count_nonmissing(): Statistics function to count non-missing values.

  • s_count_missed_doses(): Statistics function to count patients with missed doses when x is the vector of number of missed doses with one value for each patient.

  • a_count_missed_doses(): Formatted Analysis function to count non-missing values.

  • count_missed_doses(): Layout creating function which can be be used for creating summary tables for summarizing missed doses given user-specified thresholds. This is an additional layer on top of count_cumulative specifically for missed doses.

See also

Relevant description function d_count_missed_doses().

Examples

set.seed(1)
x <- c(sample(1:10, 10), NA)

# Internal function - s_count_nonmissing
if (FALSE) {
s_count_nonmissing(x)
}

# Internal function - s_count_missed_doses
if (FALSE) {
s_count_missed_doses(x = c(0, 1, 0, 2, 3, 4, 0, 2), thresholds = c(2, 5), .N_col = 10)
}

# Internal function - a_count_missed_doses
if (FALSE) {
#  We need to ungroup `count_fraction` first so that the `rtables` formatting
# function `format_count_fraction()` can be applied correctly.
afun <- make_afun(a_count_missed_doses, .ungroup_stats = "count_fraction")
afun(x = c(0, 1, 0, 2, 3, 4, 0, 2), thresholds = c(2, 5), .N_col = 10)
}

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     65 (94.2%)   67 (91.8%)     58 (100%)   
#>   At least 5 missed doses    54 (78.3%)   51 (69.9%)     54 (93.1%)  
#>   At least 10 missed doses   31 (44.9%)   40 (54.8%)     31 (53.4%)  
#>   At least 15 missed doses   17 (24.6%)   23 (31.5%)     20 (34.5%)