r/statistics • • 6d ago

Software [Software] SimtablR: Quick and Easy Epidemiological Tables, Diagnostic Tests, and Multi-Outcome Regression - version 3 now available on CRAN!

🎞Watch the short demo here: https://www.reddit.com/r/RStudio/s/K88EvqP6EC

Hello everyone! After 8 months (of rather sporadic) work, I am really excited to share the biggest update to SimtablR, an R package designed to streamline the most common analytical tasks in epidemiology and clinical research! (short demo video above)

I do epidemiological research in R, and I kept juggling multiple packages and repeating work just to get tables that were actually informative and ready for a paper. I also found that base R tabulation left a lot to be desired in terms of formatting, but gt_summary was a bit too slow and had a lot of boilerplate. This package is also great for people transitioning from Stata or still learning R!

With this new release, SimtablR now covers most of a typical analysis, from the first cross-table to the finished table in a Word document:

1. tb(): quick, but powerfull tabulation with formatting

  • Row/col/total percentages with simple flags (row, col, cell) and adjustable decimals
  • Hypothesis tests with one argument (N-1 chi-squared, Fisher when needed, etc.)
  • Prevalence ratios, risk ratios or odds ratios with 95% CIs, directly in the table
  • SimtablR now picks the right measure (RR, OR or PR) automatically for a stated study design (design = "cohort", "case_control", "cross_sectional")
  • New: stratified analysis with Mantel-Haenszel pooled estimates

2. table1(): baseline tables of multiple variables (literally the "table 1")

  • Automatically chooses mean (SD) or median (IQR) based on each variable’s distribution
  • Reports missing data per variable and group
  • Add standardized mean differences with test(smd = TRUE)
  • Completely customizable and exportable to all office programs

3. diag_test() and roc(): diagnostic accuracy

  • Automatically calculates the confusion matrix, sensitivity, specificity, PPV, NPV, LR+, LR− and accuracy, with exact (Clopper-Pearson) CIs
  • New: roc() now gives the AUC with DeLong CIs and the Youden-optimal threshold

4. regtab() and survtab(): regression

  • Fits multiple outcomes at once and returns a single publication-ready table
  • Does adjusted risk ratios via log-binomial regression (with robust Poisson fallback), robust variance, and Firth regression for rare events
  • New: survtab() for Cox models and hazard ratios
  • New: autoplot() draws forest plots from any model

5. Reporting and export (new!)

  • simtablr() builds Table 1 + Table 2 (crude and adjusted) as a single report which you can then send to word or excell or powerpoint
  • as_methods() drafts the statistical methods paragraph from what you actually did with the variables you chose!
  • export_docx() / export_xlsx() send everything to Word or Excel
  • Journal styles (style("jama"), "nejm", "lancet") or your own with journal_style(), down to the Word table theme. Restyling never changes the underlying numbers and you can use the sabe object for new analysis, even after styling!

6. Statistical guidance (new)

SimtablR prints short notes (with references) when something deserves attention. Examples: an odds ratio with a common outcome, unadjusted p-values, or when the distribution of your variable violates an assumption from the model you're running. It should just tell you.

The package includes epitabl, a ynthetic cohort of 1,500 patients, so you can replicate the examples of the video

Links:
📦 Documentation: https://matheustg-14.github.io/SimtablR/
📄 Getting started: https://matheustg-14.github.io/SimtablR/articles/getting-started.html
🐛 GitHub (issues & feature requests): https://github.com/MatheusTG-14/SimtablR

Thanks to everyone who gave feedback on the first version! I’d love to hear what you think, what’s missing from your workflow, and any bugs you find on GitHub.

11 Upvotes

2 comments sorted by

3

u/Outrageous-Mud4948 6d ago

this actually looks really useful, i spent way too much time last month just trying to get a decent table 1 for a project and ended up with messy code that i don't even remember how it worked

the statistical guidance thing is smart too, sometimes i forget to check if my model assumptions even make sense and then have to redo everything after reviewer comments

will try it out in my next analysis, the Word export might save me from copy-pasting tables all weekend

1

u/MatheusTG14 6d ago

Thanks! Let me know if you have any questions or suggestions, id be glad to help ;)