Learn R Programming

dtlg (version 0.0.2)

summary_table: Summary Table

Description

summary_table() summarises clinical variables into a report table using data.table as backend.

Usage

summary_table(
  dt,
  target,
  treat,
  target_name = target,
  indent = nbsp(n = 4L),
  .total_dt = dt,
  pct_dec = 1,
  treat_order = NULL,
  skip_absent = TRUE
)

Value

A data.table of summary statistics. The format depends on the type of the target variable:

  • If the target variable is categorical, i.e. type character, factor or logical then the output is that of calc_counts().

  • If the target variable is numeric, then the output is that of calc_desc().

Arguments

dt

A data.frame containing, at least, the variables indicated in target and treat.

target

Target variable passed as a string for which summary statistics are to be calculated.

treat

A string indicating the grouping variable, e.g. the variable specifying the treatment population.

target_name

Heading for the target variable as a string. Defaults to target.

indent

A string to be used as indentation of summary statistics labels. Defaults to four HTML non-breaking spaces ( ).

.total_dt

Separate table from dt from which to derive total counts per group.

pct_dec

Decimal places for reported figures.

treat_order

Customise the column order of the output table.

skip_absent

Whether to ignore variables passed in treat_order that are absent from dt. Default is TRUE; FALSE will throw an error in case there are missing variables.

See Also

tern_summary_table()

Examples

Run this code
dmg_vars <- c("AGE", "RACE", "ETHNIC")
dmg_var_lbls <- c("Age (yr)", "Race", "Ethnicity")

# Demographics table (DMT01)
summary_table(
  adsl,
  target = dmg_vars,
  treat = 'ARM',
  target_name = dmg_var_lbls
)

# Demographics table (DMT01) with continuous variable (e.g., BMRKR1)
summary_table(
  adsl,
  target = c(dmg_vars, "BMRKR1"),
  treat = 'ARM',
  target_name = c(dmg_var_lbls, "Biomarker 1")
)

Run the code above in your browser using DataLab