Top of the Class: Public Spending on Education

Authors: David Smale - github - twitter - LinkedIn
View the Full Tutorial - Code reproducing table - Full Repo


A gt table, customised to look like a school chalkboard, which shows changes in public spending on Elementary and Secondary Schools in the US from 1997 to 2016. The submission is in the form of a tutorial which walks through some techniques for customising a gt table.

Ever wanted to make a table look like it was written on a school chalkboard, without, y'know, actually writing on a school chalkboard? In this tutorial I walk through some techniques for customising a gt table. Along with changing fonts and colours, and adding a border, I also show how ggplot2 plots can be included in your tables. This was my first time using gt, and hopefully I've stumbled across some things that others will find useful. Because as they say, everyday is a school day!


Spending on Education - Chalkboard Table

Sometimes you just need a little nudge before delving into something new, and sometimes that little nudge is a RStudio competition. Last year I finally gave Shiny ago after seeing RStudio announce the first ever Shiny contest - and things worked out pretty well! So here I am again to try and repeat the trick, but this time - it’s tables!

In this post I’ll be using the gt package to render a table in HTML. There are several packages in R for creating tables, but I was drawn to gt (which is short for the grammar of tables) because of my love for ggplot2 (the grammar of graphics) and their shared philosophy of building output layer by layer, with the flexibility to customise the output.

For the full code to reproduce the below, go to this repo on Github: GitHub - committedtotape/education-spending: Building a table with the {gt} package, for entry into the RStudio Table Contest.

For a great introduction to the basics of gt , look no further than Thomas Mock’s blogpost, and check out his other posts on building tables in R while you’re at it! I’ll skip over some of the core building blocks that Thomas has covered, as I want to mainly focus on ways to customise a table to give it that little bit extra!

Dive into the rest of the detailed tutorial at

https://davidsmale.netlify.app/portfolio/spending-on-education/

4 Likes
Oh okay that's some cool effect. I'm an online English tutor, with this chalk board effect hopefully I'll be able to create a more classroom-like atmosphere. Y'all know how students all study online, right? They get distract very easily. However, if you know just the way to attract their attention, then your teaching quality can increase a lot more. I've looked into some other beautiful design tables on https://iunajaf.edu.iq/en/ . There're plenty of unique and beautiful tables there.
2 Likes

Hi. Thanks for sharing the statistics. I’d like to see what has changed up to now. It would be useful, I guess. Btw, thanks for sharing the links. They are helpful too. Tbh my son is about to face the toughest choice of his life. In short, he’s about to enter a university. I think I should explain that this choice will not define his whole life, but I want to help him somehow. So, I’m puzzled. We’ve found the best option so far. It’s Prague Filmmaking School (https://www.praguefilminstitute.cz/). So, he likes it but still hesitates. Any help would be appreciated.

I'm sure David would be open to your taking his code as a starting point to update things.

Looks like the data is from the US Census via the Urban Institute. As of this writing, data goes to 2019, State and Local Government Finance Data | Tax Policy Center.