3MW (Spice up your tables)

Guten Tag!

Many greetings from Ulm, Germany.

After last week's great success of creating sexy tables, we're going to double down on tables. This may or may not be related to RStudio's table contest.

Today, we're going to talk about spicy tables. That's right. Spicy! More precisely, we're going to add a couple of "regular" dataviz features to a table. This can include heatmaps, line charts, bars and all kinds of other eye-catching elements.

So, without further ado, let us spice up the following table.

Transform columns into heatmaps

In this table, we can see that Sierra Leone had by far the lowest life expectancy in 2007 (among the depicted countries). We can figure this out by comparing the numbers in the most recent column one-by-one.

But that takes quite a lot of effort. Instead, let us make that easier to see by transforming that column into a heatmap.

We could also do this for more columns. For example, we could also do the same with the 1957 column.

You could even do that with all columns. But I am not sure whether that's a good idea here. After all, we do not want to overload our table with colors.

Add sparklines

It is quite hard to figure out that each depicted country increased its life expectancy in each year. Sure, you may have an idea that this is the case. But to be sure for real, you will have to compare each cell of each row.

Why don't we make that a little bit easier? Let us add small line charts. This kind of chart is known as a sparkline. It's main advantage is that it can make patterns really obvious. Have a look for yourself.

Add bullet charts

The data set that was used to create this table is larger than what we show here. In fact, we have the same data for many more countries. But showing all of that information would make the table HUUUGE.

But we could still use that information. Here, we can put the life expectancies of our selected countries into context. For example, for each country let us compare its life expectancy to the mean life expectancy of its continent .

A so-called bullet chart will do the trick. Check it out.

(I've removed the sparkline because this newsletter format is quite narrow. In a wider format, you could use a sparkline and a bullet chart without sacrificing legibility.)

Recommended Resources

  1. All of the previous tables were created with {gt} and {gtExtras}. You can find the corresponding code on GitHub.

  2. Want more ideas? I've got you covered. Here's another one from me. I created this table a while back and I erroneously labeled the quantile ranges as confidence intervals. Nevertheless, the idea works the same for quantile ranges and confidence intervals.

  3. Another idea comes from Daniel Sjoberg. He recently shared a tweet that showed the use of emojis in tables and - even cooler - tables in tables. You can find his post on Twitter.

That's a wrap! As always, I'm happy to hear your feedback about this week's issue. Feel free to write me on Twitter or reply to this mail.

Enjoy the rest of your day!Albert

Did you like this post and want to support more content like this? Whenever you feel like it, you can support me with a coffee or a membership.

Reply

or to participate.