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)

d_count_missed_doses(thresholds)

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.

d_count_missed_doses() returns a named character vector with the labels.

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.

  • d_count_missed_doses(): Description function that calculates labels for s_count_missed_doses().

  • 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.

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)
library(scda)
adex <- synthetic_cdisc_data("latest")$adex
adsl <- synthetic_cdisc_data("latest")$adsl
anl <- adex %>%
  distinct(STUDYID, USUBJID, ARM) %>%
  mutate(
    PARAMCD = "TNDOSMIS",
    PARAM = "Total number of missed doses during study",
    AVAL = sample(0:20, size = nrow(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 = adsl)
#>                               A: Drug X    B: Placebo    C: Combination
#>                                (N=134)       (N=134)        (N=132)    
#> ———————————————————————————————————————————————————————————————————————
#> Missed Doses                                                           
#>   n                              134           134            132      
#>   At least 1 missed dose     127 (94.8%)   127 (94.8%)    124 (93.9%)  
#>   At least 5 missed doses    102 (76.1%)   105 (78.4%)     98 (74.2%)  
#>   At least 10 missed doses   64 (47.8%)    72 (53.7%)      65 (49.2%)  
#>   At least 15 missed doses   42 (31.3%)    41 (30.6%)      32 (24.2%)