Usage
s_num_patients(x, labelstr, .N_col, count_by = NULL)
s_num_patients_content(
  df,
  labelstr = "",
  .N_col,
  .var,
  required = NULL,
  count_by = NULL
)
summarize_num_patients(
  lyt,
  var,
  .stats = NULL,
  .formats = NULL,
  .labels = NULL,
  ...
)Arguments
- x
 (
characterorfactor)
vector of patient IDs.- labelstr
 (
character)
label of the level of the parent split currently being summarized (must be present as second argument in Content Row Functions).- .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 byrtables.- count_by
 (
characterorfactor)
optional vector to be combined withxwhen countingnonunqiuerecords.- df
 (
data frame)
data set containing all analysis variables.- .var, var
 (
string)
single variable name that is passed byrtableswhen requested by a statistics function.- required
 (
characterorNULL) optional name of a variable that is required to be non-missing.- lyt
 (
layout)
input layout where analyses will be added to.- .stats
 (
character)
statistics to select for the table.- .formats
 (named
characterorlist)
formats for the statistics.- .labels
 (named
character)
labels for the statistics (without indent).- ...
 additional arguments for the lower level functions.
Value
A list with:
unique: vector of count and percentage.nonunique: vector of count.unique_count: count.
Functions
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(): 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. Function serves as a wrapper that carries over both expected argumentsdfandlabelstrincfunofsummarize_row_groups().summarize_num_patients(): Layout creating function which adds content rows using the statistics functions_num_patients_content()and desired format.
Examples
# 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)
#> $unique
#> [1] 3.0 0.5
#> 
#> $nonunique
#> [1] 5
#> 
#> $unique_count
#> [1] 3
#> attr(,"label")
#> [1] " (n)"
#> 
s_num_patients(
  x = as.character(c(1, 1, 1, 2, 4, NA)),
  labelstr = "",
  .N_col = 6L,
  count_by = as.character(c(1, 1, 2, 1, 1, 1))
)
#> $unique
#> [1] 3.0 0.5
#> 
#> $nonunique
#> [1] 4
#> 
#> $unique_count
#> [1] 3
#> attr(,"label")
#> [1] " (n)"
#> 
# 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")
#> $unique
#> [1] 3.0 0.6
#> 
#> $nonunique
#> [1] 4
#> 
#> $unique_count
#> [1] 3
#> attr(,"label")
#> [1] " (n)"
#> 
df_by_event <- 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_by_event, .N_col = 5, .var = "USUBJID")
#> $unique
#> [1] 3.0 0.6
#> 
#> $nonunique
#> [1] 4
#> 
#> $unique_count
#> [1] 3
#> attr(,"label")
#> [1] " (n)"
#> 
s_num_patients_content(df_by_event, .N_col = 5, .var = "USUBJID", count_by = "EVENT")
#> $unique
#> [1] 3.0 0.6
#> 
#> $nonunique
#> [1] 3
#> 
#> $unique_count
#> [1] 3
#> attr(,"label")
#> [1] " (n)"
#>