table1: Table One Tibbles

Description Usage Arguments Details Value

Description

Functions for producing descriptive statistics for numeric and categorical data. The objective of these functions is to make it easier to produce "Table 1" for a manuscript.

Tables are seperately created for numeric and categorical variable, and need to be combined manually afterward (probably using bind_rows).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
table1_numeric(
  data,
  ...,
  group = NULL,
  round = 2,
  digits = round,
  total = FALSE,
  na.rm = FALSE
)

table1_categorical(
  data,
  ...,
  group = NULL,
  round = 2,
  digits = round,
  total = FALSE,
  na.rm = FALSE,
  na_level = "(Missing)"
)

Arguments

data

Data frame.

...

Columns to summarise.

group

Grouping variable for group summaries.

round

Number of digits for rounding statistics (where applicable).

digits

Number of significant digits to print (pad with zeroes if digits < round)

total

Logical. Should a total column be added? (Default is FALSE) This argument only matters when a grouping variable is provided.

na.rm

Logical. Should missing data be remove before computing summary statisitcs? (Default is FALSE)

na_level

String to display for missing levels.

Details

For numeric variables passed to table1_numeric, the returned summary statistics are means (mean) and standard deviations (sd). For categorical variables (i.e. factors) passed to table1_categorical, the returned summary statistics are counts (sum) and percentages (mean) of indicator variables for each level in a factor variable.

Value

A tibble with as many rows as the number of columns provided to ..., and as many columns as levels in group. Cell values are glue objects.


mattwarkentin/sandbox documentation built on Jan. 29, 2020, 4:46 p.m.