Public Health Night School

Public Health Night School

Biostatistics

Goodbye Pivot Table Panic: Summarizing Public Health Data in R

Post 4 of 5 in the series: From Spreadsheets to Scripts

Jul 03, 2026
∙ Paid
a person holding a piece of paper over a laptop
Photo by Jakub Żerdzicki on Unsplash

Pivot tables are one of Excel’s best features. The problem is not that they are bad. The problem is that they can be hard to document, recreate, and automate.

You build a pivot table. It looks right. Two weeks later, someone asks you to update it with the new data. You open the file, click Refresh, and something breaks. Either a field moved, a filter was reset, or the source range did not expand to include the new rows. Or you need the same table for twelve counties instead of one, and the only way to do it is to build twelve pivot tables by hand.

In R, the summaries that would require pivot tables are written as a few lines of code. They run on any version of the data. They produce the same result every time. And they document themselves.

User's avatar

Continue reading this post for free, courtesy of René F. Najera.

Or purchase a paid subscription.
© 2026 EpiVeritas Analytics & Consulting, LLC. · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture