And impressions of the {gt} package.
is is going to be a pretty short post. After seeing the Rstudio Table Contest announced a few weeks ago, I decided that I wanted to submit something to give myself more of a reason to practice with the {gt}
package. I (somewhat arbitrarily) chose to use some longitudinal Broadway data posted earlier in the year as part of #TidyTuesday that I thought would lend itself well to a table.
Anyway, below is my submission to the contest, and below that are some initial impressions of the {gt}
package (tl;dr – it’s pretty awesome).
Top Earning Broadway Shows | |||||||
---|---|---|---|---|---|---|---|
through 2019 | |||||||
Rank | Show | Premiere Year | Total Earnings | Avg Theater Capacity Filled |
Tickets Sold Per Year | ||
Average | 1987 - 2019 | ||||||
1 | The Lion King | ![]() |
1997 | $1.66B | 97.7% | 676,795 | |
2 | Wicked | ![]() |
2003 | $1.35B | 97.2% | 708,412 | |
3 | The Phantom of the Opera | ![]() |
1988 | $1.24B | 89.8% | 600,508 | |
4 | Chicago | ![]() |
1996 | $673.91M | 82.7% | 392,534 | |
5 | The Book of Mormon | ![]() |
2011 | $647.07M | 102.4% | 445,435 | |
6 | Mamma Mia! | ![]() |
2001 | $624.39M | 89.7% | 504,408 | |
7 | Hamilton | ![]() |
2015 | $620.60M | 101.7% | 498,052 | |
8 | Jersey Boys | ![]() |
2005 | $557.51M | 89.5% | 395,571 | |
9 | Les Miserables | ![]() |
1987 | $548.80M | 88.5% | 353,014 | |
10 | Aladdin | ![]() |
2014 | $447.72M | 98.0% | 686,539 | |
Data: Playbill | Table: Eric Ekholm (@ekholm_e) |
Right, so, my overall impression of {gt}
is that it’s an amazing package for building stylized static tables that fills a gap in R’s table ecosystem (to the extent that’s a thing). In my day job, I often find myself having to build tables either 1) as part of documents I’m creating on my own or 2) as stand-alone pieces that end up getting dropped into Powerpoints other people are putting together, and I’m excited about incorporating {gt}
into my workflow for both of those types of tasks. Some more specific impressions of {gt}
:
{ggtplot2}
. This isn’t surprising, given that the intent of the package is to provide a “grammar of tables.” But the flow & general process felt very familiar to me even though I haven’t used it extensively before, and I imagine anyone else who’s reasonably proficient using ggplot will feel the same when picking up gt. Which is a big plus, because it mitigates a lot of that difficulty of learning a new package.{ragg}
package seems to have made using fonts in ggplot easier, though. That said, using any Google font in gt is as easy as dropping in the google_font()
function and voila, it works! Such a nice change of pace after my typical long troubleshooting sessions with fonts in ggplot.tab_style()
function, which I’ll open an issue for. I found a workaround, but it involved essentially stylizing the same element multiple times, which doesn’t feel ideal.Overall, {gt}
is a really awesome package – huge thanks to the team at Rstudio for putting it together and maintaining it!
For attribution, please cite this work as
EE (2020, Oct. 26). Eric Ekholm: Rstudio Table Contest Submission. Retrieved from https://www.ericekholm.com/posts/2021-01-11-rstudio-table-contest-submission/
BibTeX citation
@misc{ee2020rstudio, author = {EE, }, title = {Eric Ekholm: Rstudio Table Contest Submission}, url = {https://www.ericekholm.com/posts/2021-01-11-rstudio-table-contest-submission/}, year = {2020} }