Skip to contents

dh.getStats extracts key statistics and stores them in a clientside list. dh.createTableOne builds on this by formatting the extract stats into a table which can then be included in a manuscript. Flexible formatting options are included.

Usage

dh.createTableOne(
  stats = NULL,
  vars = NULL,
  var_labs = NULL,
  cat_labs = NULL,
  type = NULL,
  coh_labs = NULL,
  coh_direction = "cols",
  cont_format = NULL,
  inc_missing = NULL,
  sig_digits = 3,
  perc_denom = NULL
)

Arguments

stats

Exported object from dh.getStats.

vars

Variable to be included in table.

var_labs

Tibble with two columns: 'variable' containing the names of the variables specified in vars, and 'var_label' containing the replacement labels for these variables.

cat_labs

Tibble with three columns: 'variable' containing the names of the categorical variables specified in vars, 'category' containing the categories of these variabels, and "cat_label" containing the replacement category labels for these variables.

type

Character specifying which cohorts to include in the table. If "combined" then only combined stats will be returned, if "cohort" then only cohort-specific stats will be returned, if "both" then everything will be returned.

coh_labs

Tibble with two columns: 'cohort' containing the names of all cohorts included in stats, and 'cohort_labs' containing the replacement labels for these cohorts.

coh_direction

Character specifying direction of data if type is 'cohort' or 'both'. Use 'rows' to return cohorts as rows and variable as columns, or use 'cols' to return cohorts as columns and variables as rows. Defauls is "col".

cont_format

Character specifying which summary statistic to return for continuous stats. Use 'med_iqr' to return the median and interquartile range, use 'mean_sd' to return the mean and standard deviation. Default is "med_iqr".

inc_missing

Boolean specifying whether to return missing values in the output. Use TRUE for yes and FALSE for no.

sig_digits

Optionally, the number of decimal places to round output to. Default is 2.

perc_denom

The denominator for percentages. Either 'valid' for valid cases or 'total' for total cases.

Value

Tibble containing formatted summary statistics. If coh_direction is 'cols', the tibble will contain four columns: 'cohort', 'variable', 'category' & value. If coh_direction is rows, the tibble will contain the column 'cohort' as well as as columns for all continuous variables and all categories of categorical variables.

See also

Other descriptive functions: dh.anyData(), dh.classDiscrepancy(), dh.getStats(), dh.lmTab(), dh.meanByGroup()