R is not that great for final product data visualization, but if there was a simple way to give my plain tables a little love, I figured, ‘Why not?’ So I asked The Google, and it brought me to this demo by Hao Zhu, creator of the kableExtra R package. The features to manipulate table styles seemed straightforward enough for a noob like me with no experience programming in CSS, so I decided to give it a run. The lucky table chosen for the makeover was from tabular data to calculate location quotients (LQs) in Las Vegas. The LQs quantified how concentrated a particular industry is in a region as compared to the nation. Specifically, I wanted to highlight the obvious about my table: gaming and hospitality drives the Vegas economy. It took a few iterations, but I figured out how to style everything the way I wanted (after augmentation with the formattable package). Check out the before and after tables below.

This is the basic HTML table in kable:

And here’s the makeover after some formatting help from kableExtra.

=======

Learning points

  • It’s a nice bundle of functions. It’s one that is easy to use and easy to understand; thus, it should be popular for those looking to keep the simplicity of the Bootstrap table style while adding flexible customization. It’s better suited for model-output documents and statistical result-type tables, rather than for fully leveraging on the power of visualization to help interpret the data.