Summary Tables with 'tab'"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>", 
  message = FALSE
)

# Load packages
library("tab")
library("knitr")
library("gee")

# Set xtable options
options("xtable.caption.placement" = "top", 
        "xtable.include.rownames" = TRUE, 
        "xtable.comment" = FALSE)

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 in 2 extra keystrokes

GLM's

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.

Linear regression

Here's a linear regression of BMI on age, sex, and race. Once you call glm_v, a summary table will pop up in the RStudio Viewer.

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

Figure

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.

Logistic regression

Of course glm supports all sorts of regression models, and glm_v should play nice at least with the more common ones. Here's a logistic regression for 1-year mortality vs. age, BMI, and sex, with some higher-order terms:

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

Figure



Try the tab package in your browser

Any scripts or data that you put into this service are public.

tab documentation built on Aug. 2, 2021, 9:06 a.m.