The goal of the tibbleOne package is to make it easy for analysts to include a Table 1 object in both LaTeX and html markdown documents. I made this package because I was unable to get the html tables I wanted from the existing table one R packages. Notably, this package has far fewer features than the outstanding TableOne package, but it can get a readable Table 1 object into a markdown document with less effort.

Installation

You can install the latest version of tibbleOne from github with:

devtools::install_github('bcjaeger/tibbleOne')

Example

For a more detailed example, see the ‘start here’ vignette. This example shows basic elements of tibbleOne.


library(knitr)
library(kableExtra)
library(tibbleOne)
library(tidyverse)

The first step should be setting labels for the variables that will be in the table. This can be done using set_variable_labels and then building a meta data set. You may also just pipe the labelled dataset into tibble_one(), but it is generally more useful to keep the meta data object in case you need to use the labels for other tables in your analysis.

Last step, we pass tbl_one into the to_kable() function, which provides a couple of nice formatting procedures to make the data look like the type of Table 1 that you may see in a published article.

Characteristics of patients with primary biliarry cirrhosis.
Treatment group
Overall
(N = 418)
D-penicillmain
(N = 158)
Placebo
(N = 154)
P-value
Age 50.7 (10.4) 51.4 (11.0) 48.6 (9.96) 0.018
Female, % 89.5 86.7 90.3 0.421
Status at last contact, % 0.894
Censored 55.5 52.5 55.2
Transplant 5.98 6.33 5.84
Dead 38.5 41.1 39.0
Stage, % 0.201
One 5.10 7.59 2.60
Two 22.3 22.2 20.8
Three 37.6 35.4 41.6
Four 35.0 34.8 35.1
Ascites, % 7.69 8.86 6.49 0.567
Bilirubin levels 3.22 (4.41) 2.87 (3.63) 3.65 (5.28) 0.133
Edema, % 0.877
None 84.7 83.5 85.1
Untreated or successfully treated 10.5 10.1 8.44
Treatment resistant 4.78 6.33 6.49
Serum Albumin 3.50 (0.42) 3.52 (0.44) 3.52 (0.40) 0.874
\* Table values are mean (standard deviation) and percent for continuous and categorical variables, respectively.