The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Summary Tables with ‘tab’

Dane Van Domelen
vandomed@gmail.com

2021-08-01

Installation

You can install and load tab from GitHub via the following code:

devtools::install_github("vandomed/tab")
library("tab")

Functions

The main purpose of tab is to create neatly formatted summary tables for papers and presentations. The following functions are included:

Regression summaries with just 2 extra keystrokes

To summarize a fitted generalized linear model, simply call glm_v as you would glm. The result will be a formatted summary table printed to the RStudio Viewer. Here’s an example for logistic regression:

glm_v(
  death_1yr ~ poly(Age, 2, raw = TRUE) + Sex * BMI, 
  data = tabdata, 
  family = binomial
)

From here, you can “snip” the summary table and save it as a figure (as I did for this README) or copy directly from the Viewer and paste outside of R.

For more flexibility, see tabglm. That function lets you control things like what columns to present, how categorical predictors are presented, and so on.

Summary tables for continuous and categorical variables

You can use tabmulti to summarize variables across two or more groups, using a formula interface. Here’s an example:

tabmulti(Age + Sex + Race + BMI ~ Group, data = tabdata)

Compatibility with Markdown/Knitr

The functions all return kable objects, so they should work perfectly well in R Markdown and knitr documents.

References

Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.

———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Chapman; Hall/CRC.

———. 2021. Knitr: A General-Purpose Package for Dynamic Report Generation in R.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.