You can install and loadtab from GitHub via the following code:
The main purpose oftab 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 Viewertabglm summarizes generalized linear models (GLM’s) fit viaglm orsurvey::svyglmtabgee summarizes generalized estimating equation models (GEE’s) fit viagee::geetabcoxph summarizes Cox Proportional Hazards models fit viasurvival::coxph orsurvey::svycoxphtabmulti compares variables across two or more groups, e.g. to create a “Table 1”tabmulti.svy does the same thing astabmulti but for complex survey dataTo summarize a fitted generalized linear model, simply callglm_v as you wouldglm. The result will be a formatted summary table printed to the RStudio Viewer. Here’s an example for logistic regression:
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, seetabglm. That function lets you control things like what columns to present, how categorical predictors are presented, and so on.
You can usetabmulti to summarize variables across two or more groups, using a formula interface. Here’s an example:
The functions all returnkable objects, so they should work perfectly well in R Markdown and knitr documents.
Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” InImplementing 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.