baselineTable: A Baseline Table/ Descriptive Statistics function

Description Usage Arguments Author(s) Examples

View source: R/baselineTable.R

Description

This function creates a baseline table including descriptive statistics and automates work for a "Table 1" in scientific publications.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
baselineTable(
  data,
  vars,
  labels = NULL,
  grouping.var = NULL,
  round_dec = 2,
  placeholder = "   ",
  welch.test = FALSE,
  na.statistics = "all",
  print.vars = FALSE
)

Arguments

data

Data needs to be entered that includes relevant variables for the baseline table

vars

Vector of variables to be included as rows for baseline Table

labels

Vector of labels to be set in rows for baseline Table. Needs to be the same length as vars. Defaults to vars values.

grouping.var

Optional variable name if you want to include extra rows (and statistical tests) for baseline variables split by groups.

round_dec

Number of decimal spaces to-be-included in baseline Table. Default is 2

placeholder

The placeholder can be specified with indents descriptive statistics labels (e.g., Mean (SD)) by a given string. The default is " " (i.e., three spaces).

welch.test

If grouping.var is specified and includes two groups only, The Welch test will be used to test for significant differences between groups on continuous variables. Default is FALSE.

na.statistics

Should Missing value estimates be included in the output? Default is "all"; i.e., to provide all missingness statistics. Other options include "if.applicable" and "none". "if.applicable" includes missingness statistics for those variables, where NAs are present.

print.vars

Should variable names be included in the output (in addition to labels)? Default is FALSE.

Author(s)

Nils Kappelmann

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data("airquality")
airquality$Period = ifelse(airquality$Month %in% 5:7, "Early Summer", "Late Summer")

baselineTable(data = airquality,
vars = c("Ozone", "Solar.R",
"Wind", "Temp", "Period"))
baselineTable(data = airquality,
vars = c("Ozone", "Solar.R",
"Wind", "Temp", "Period"),
labels = c("Ozone (ppb)", "Solar R (lang)",
"Wind (mph)", "Temperature (degrees F)", "Period"))
baselineTable(data = airquality,
vars = c("Ozone", "Solar.R", "Wind", "Temp"),
labels = c("Ozone (ppb)", "Solar R (lang)",
"Wind (mph)", "Temperature (degrees F)"),
grouping.var = "Period", round_dec = 1)

nkappelmann/PubHelper documentation built on Aug. 7, 2021, 5:09 a.m.