Automating Tables in R

How can we make tables repeatable?

Anthony B. Masters
The Startup

--

Last week, I looked at estimating systematic differences between UK polling companies.

This article looks at remaking the house effects table in the gt package in R.

The table

For regular reporting, we often need to make reproducible graphs and tables.

The outputs were the estimated constants in generalised additive models. That model has the components:

  1. Company-weighted average: a constant representing the average reading. Each company has the same weight.
  2. Smooth function of time: this is a smooth function of the number of days since the last election. That smooth function must average to zero.
  3. The house effect: for each company, there is an change to fit to the ‘average company’ vote intention over time.

Here, the models assume house effects are constant, and do not vary in time. House effects are relative to the industry average. Centrality does not mean accuracy. The table shows:

The house effects are relative to the industry average, with 95% confidence intervals.

The goal is to show, for each company: count, plus ‘house effect’ estimates and intervals by party.

I made this table in LaTeX. It has a professional look, but there are problems:

--

--

Anthony B. Masters
The Startup

This blog looks at the use of statistics in Britain and beyond. It is written by RSS Statistical Ambassador and Chartered Statistician @anthonybmasters.