Make data display tables prettier with {gt} #datascience
image: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
gt right now is my favorite package for building pretty data display tables. It offers a bunch of tools to help you get your display tables exactly the way you want them to look. One thing I love is the calls merge helper function. It lets you combine multiple values into a single table column.
For example, suppose we have a data set with separate variables for latitude and longitude but we want to combine them into a coordinates column in our display table. Calls merge lets us select the columns to merge and define how they should look when combined. Now look at the station name and caption variables. Suppose we want to combine these two into a single column and clean up those missing values. Here we add the station caption only if the caption exists.
I don't know about you but before gt I found myself using dplyr's mutate function to handle these kind of column merging actions. But that's not right. You often have to convert numeric factor or date time values into text and doing so you lose information like order and things can get weird fast. These gt helper functions help you avoid these.
You often have to convert numeric factor or date time values into text and doing so you lose information like order and things can get weird fast. These gt helper functions help you avoid these.