How to Add Trendlines to your GT Tables in R

Phillip Heita
4 min readDec 19, 2021

Have the best of both worlds by combining GT tables and trendlines to better communicate with different stakeholders in R.

Tables allow for a diverse audience, each looking up specific information of interest. In the table above, you might only be interested in your country, whereas graphs present a lot of data quickly and in an easy to consume format. Overall, the goal of a good visualization should be to make as much information as intuitively understandable as possible for varying stakeholders. Trendlines can go a long way in showing the trend within your data, especially when combined with tabular data.

For this article, we will combine GT tables and trendlines in R. The inspiration comes from a LinkedIn post by Christian Eilert, FRM, showing an excellent looking GT table (without trendlines) on the current OECD's Economic outlook projections.

OECD R package

The Organization for Economic Cooperation and Development (OECD) has an extensive database on different economic and socio-demographic indicators. The OECD package allows you to access data from the OECD's API in a dynamic and reproducible way, which you can leverage in adding even more context to your analysis in telling a compelling story.

Imports

--

--

Phillip Heita

I am a finance professional, with intersecting interests in credit risk, fintech, and software engineering.