Sometime data viz people dump on tables a little bit (I’ve done it), as not being able to very efficiently communicate information. But this is probably because they are not doing it right.
Data visualization uses all these super-speed channels: position, color, size. In fact, visuals can also be quite strong in well formatted tables; they also use encoding and meaning for visual cues. With the help of table formatting packages, we can do better at making more attractive tables that aid efficient understanding and use! Nice!
Okay, but there are a lot of table formatting tools out there – just in R. How do I know which one to use?
This is the outline of an resource page on table formatting in R. Some parts are more filled in, but a lot is missing.
I’m using flipbooks. Because the formatting tools are so visual – it is a fun to watch the outputs evolve and it is easy to identify parts of the pipeline that are relevant to what you want to get done. I think they can help show how the different API’s work in a detailed and accessible way. Lot’s of info, but presented in stacks of slides, it doesn’t feel overwhelming – I hope!
I’m using a new flipbook function: embed_flipbook() and there are some wrinkles to work out. You may even see some error messages related to this! Work in progress. Embedded flipbooks benefit a lot from xaringanExtra, and flipbooks benefit from {xaringan} itself!
Tables have been an inspiration for moving the flipbook project forward too, to thinking more about flipbooks in documentation and specifically motivating “rotate” and “replace” modes for such work. Thanks especially {gt}!
Let’s start with a motivating example. Of my tables, my favorite is probably this named colors table. It is nice and compact and the you can copy and paste the names of the colors. I made it with {gt}. Then we’ll give you a birds eye view on some table formatting packages in R.
This comparison table summarizes a lot of information about table packages: what outputs the package supports. Even if you like the way a package’s table looks in html, if you can’t output to the format you need, you probably don’t want to go too far down that road.
It is put together by Daniel Sjoberg and use with permission! He built the table with {gt}, and we reproduce much of the build here.
Print Engine | Function | HTML | RTF | Word | |
---|---|---|---|---|---|
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
Error : Problem with `filter()` input `..1`.
x subscript out of bounds
ℹ Input `..1` is `line %in% which_highlight_frame`.
Error : Problem with `filter()` input `..1`.
x subscript out of bounds
ℹ Input `..1` is `line %in% which_highlight_frame`.
This section just compares to builds from two separate packages, but would ideally compare the full set of packages. The results are similar, but APIs are a bit different.
Year | The Country Name | lifeExp | Population | gdpPercap | |
2002 | Asia | Afghanistan | 42.129 | 25268405 | 726.7341 |
Europe | Albania | 75.651 | 3508512 | 4604.2117 | |
Africa | Algeria | 70.994 | 31287142 | 5288.0404 | |
Angola | 41.003 | 10866106 | 2773.2873 | ||
Americas | Argentina | 74.340 | 38331121 | 8797.6407 | |
Oceania | Australia | 80.370 | 19546792 | 30687.7547 |
year | continent | country | lifeExp | pop | gdpPercap |
---|---|---|---|---|---|
2002 | Asia | Afghanistan | 42.1 | 25268405 | 727 |
Europe | Albania | 75.7 | 3508512 | 4.6e+03 | |
Africa | Algeria | 71 | 31287142 | 5.29e+03 | |
Angola | 41 | 10866106 | 2.77e+03 | ||
Americas | Argentina | 74.3 | 38331121 | 8.8e+03 | |
Oceania | Australia | 80.4 | 19546792 | 3.07e+04 |