Goodbye Pivot Table Panic: Summarizing Public Health Data in R
Post 4 of 5 in the series: From Spreadsheets to Scripts
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.


