GithubHelp home page GithubHelp logo

vandomed / tab Goto Github PK

View Code? Open in Web Editor NEW
2.0 0.0 5.0 1.3 MB

Create Summary Tables for Statistical Reports

License: GNU General Public License v3.0

R 100.00%
tables reports manuscripts reproducible-research statistics

tab's Introduction

Summary Tables with ‘tab’

Dane Van Domelen
[email protected] 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:

  • glm_v prints a GLM summary table to the RStudio Viewer
  • tabglm summarizes generalized linear models (GLM’s) fit via glm or survey::svyglm
  • tabgee summarizes generalized estimating equation models (GEE’s) fit via gee::gee
  • tabcoxph summarizes Cox Proportional Hazards models fit via survival::coxph or survey::svycoxph
  • tabmulti compares variables across two or more groups, e.g. to create a “Table 1”
  • tabmulti.svy does the same thing as tabmulti but for complex survey data

Regressions

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
)

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.

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)

Figure

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.