Stable lifecycle

Table one is a tabular description of characteristics, e.g., demographics of patients in a clinical trial, presented overall and also stratified by a categorical variable, e.g. treatment group.

tibble_one(data, formula = NULL, meta_data = NULL, row_vars = NULL,
  strat = NULL, by = NULL, specs_table_vals = NULL,
  specs_table_tests = NULL, include_pval = FALSE,
  expand_binary_catgs = FALSE, include_freq = FALSE,
  add_perc_to_cats = TRUE)

Arguments

data

a data frame

formula

an optional formula object. The left hand side of the formula should be blank. The right hand side of the formula should contain row variables for the table. The '|' symbol can be used to include stratifying variables. If this option is used, no more than two stratifying variables should be used, and they must be separated by a * symbol. If formula is used, the strat, by, and row_vars inputs are ignored.

meta_data

a meta data frame. If unspecified, a meta data frame will be created using data.

row_vars

a character vector indicating column names of row variables in the table. If unspecified, all columns are used.

strat

a character value indicating the column name in data that will be used to stratify the table

by

a character value indicating the column name in data that will be used to split the table into groups, prior to stratification.

specs_table_vals

named vector of character values. Names should be variables, while values should be specs. Valid specs are 'mean' and 'median' (see examples).

specs_table_tests

named vector of character values. Names should be variables, while values should be specs. Valid specs are 'params' or 'noparm' (see examples).

include_pval

T/F, should the table include a column for p-values? If p-values are included, factor variables are handled using chi-square tests, continuous variables are handled using t-tests or ANOVA, depending on the number of categories in the table stratification.

expand_binary_catgs

T/F, should all categories be included for binary categorical variables? (This only applies to binary variables.)

include_freq

T/F, should frequency values be included for categorical variables?

add_perc_to_cats

T/F, should categorical variable labels be appended with a percent sign?

Value

a tibble containing summary values that describe characteristics of observations in data , which can subsequently be sent to different modes of output (see to_word and to_kable).

Examples

data("pbc_tbl1") # report median albumin instead of mean # use kruskal wallis test for albumin tibble_one( pbc_tbl1, formula = ~ . | trt, include_freq = FALSE, include_pval = TRUE, specs_table_vals = c(albumin = 'median'), specs_table_tests = c(albumin = 'nopars') )
#> # A tibble: 19 x 7 #> group variable labels Overall `D-penicillmain` Placebo `P-value` #> <fct> <fct> <chr> <chr> <chr> <chr> <chr> #> 1 None descr No. of observ~ 418 158 154 "" #> 2 None age Age 50.7 (10.~ 51.4 (11.0) 48.6 (9.~ 0.018 #> 3 None sex Female, % 89.5 86.7 90.3 0.421 #> 4 None status Status, % "" "" "" 0.894 #> 5 None status Censored 55.5 52.5 55.2 "" #> 6 None status Transplant 5.98 6.33 5.84 "" #> 7 None status Dead 38.5 41.1 39.0 "" #> 8 None stage Stage, % "" "" "" 0.201 #> 9 None stage One 5.10 7.59 2.60 "" #> 10 None stage Two 22.3 22.2 20.8 "" #> 11 None stage Three 37.6 35.4 41.6 "" #> 12 None stage Four 35.0 34.8 35.1 "" #> 13 None ascites Ascites, % 7.69 8.86 6.49 0.567 #> 14 None bili Bili 3.22 (4.4~ 2.87 (3.63) 3.65 (5.~ 0.133 #> 15 None edema Edema, % "" "" "" 0.877 #> 16 None edema None 84.7 83.5 85.1 "" #> 17 None edema Untreated or ~ 10.5 10.1 8.44 "" #> 18 None edema Treatment res~ 4.78 6.33 6.49 "" #> 19 None albumin Albumin 3.53 [3.2~ 3.56 [3.21-3.83] 3.54 [3.~ 0.874