Skip to contents

The goal of tableone is to make it easy to generate comparison tables for journal publication. It converts a line list of experimental or observational data into a summary table which can be grouped by an intervention. Reporting summaries of this kind of data has to be aware of missing items, and provide summary statistics and statistical comparisons that are appropriate for the data. This is amenable to some automated decision making but frequently such automation must be overridden. tableone provides an automated one command statistical summary table the output of which is highly configurable. The resulting tables are in huxtable format ready for export into a wide range out file types.

Installation

There is a different tableone package on CRAN. This package is hosted in the Bristol Vaccine Centre r-universe. Installation from there is as follows:

options(repos = c(
  "bristol-vaccine-centre" = 'https://bristol-vaccine-centre.r-universe.dev/',
  CRAN = 'https://cloud.r-project.org'))

# Download and install tableone in R
install.packages("tableone")

You can install the development version of tableone from GitHub with:

# install.packages("devtools")
devtools::install_github("bristol-vaccine-centre/tableone")

Example

tableone is there to make descriptive statistics consistent and easy. Summarising the dataset in a a nicely formatted summary table is as simple as the following code. For the proper formatted output head to the main documentation website.

# hide messages 
old = options(tableone.quiet = TRUE)

# generate table 
iris %>% 
  describe_population(everything()) 
Variable Characteristic Value Count (N=150)
Sepal.Length Mean ± SD 5.84 ± 0.828 150
Sepal.Width Mean ± SD 3.06 ± 0.436 150
Petal.Length Median [IQR] 4.35 [1.6—5.1] 150
Petal.Width Median [IQR] 1.3 [0.3—1.8] 150
Species setosa % [95% CI] 33.3% [26.3%—41.2%] 50/150
versicolor % [95% CI] 33.3% [26.3%—41.2%] 50/150
virginica % [95% CI] 33.3% [26.3%—41.2%] 50/150
Normality of distributions determined using Anderson-Darling normality test

As a huxtable output the table can be saved as a wide range of formats from spreadsheets or documents to latex and html (even as a github README.md with limited success). This default output of tableone can be very substantially customised to fit into a specific journal’s requirements.