Rich Iannone || New features in {gt} 0.6.0! || RStudio
00:00 Introduction
00:18 sub_missing()
03:51 Markdown formatting in sub_missing()
04:51 sub_zero()
07:34 sub_small_vals()
13:08 sub_large_vals()
16:25 final thoughts
A new version of the R package {gt} has been released! We are now at version `0.6.0` and there are now even more features that'll make your display/summary tables look and work much, much better. Let's run through some of the bigger changes and see the benefits they can bring!
New functions for substituting cell data
We now have four new functions that allow you to make precise substitutions of cell values with perhaps something more meaningful. They all begin with `sub_` and that's short for substitution!
sub_missing() (formerly known as fmt_missing())
Here's something that's both old and new. The sub_missing() function (for replacing NAs with... something) is new, but it's essentially replacing a function that is old (fmt_missing()).
The missing_text replacement of "---" is actually an em dash (the longest of the dash family). This can be downgraded to an en dash with "--" or we can go further with "-", giving us a hyphen replacement. Or, you can use another piece of text.
If you're using and loving fmt_missing(), it's okay! You'll probably receive a warning about it when you upgrade to {gt} 0.6.0 though. Best to just substitute fmt_missing() with sub_missing() anyway!
sub_zero()
The sub_zero() function allows for substituting zero values in the table body.
sub_small_vals()
Next up is the sub_small_vals() function. Ever have really, really small values and really just want to say they are small?
With sub_small_vals() we can reformat smaller numbers using the default threshold of 0.01.
Small and negative values can also be handled but they are handled specially by the sign
parameter. Setting that to "-" will format only the small, negative values.
You don't have to settle with the default threshold value or the default replacement pattern
(in small_pattern). This can be changed and the "x" in small_pattern (which uses the
threshold value) can even be omitted.
sub_large_vals()
Okay, there's one more substitution function to cover, and this one's for all the large values in your table: sub_large_vals(). With this you can substitute what you might consider as too large values in the table body.
Large negative values can also be handled but they are handled specially by the sign parameter. Setting that to "-" will format only the large values that are negative.
You don't have to settle with the default threshold value or the default replacement pattern (in large_pattern). This can be changed and the "x" in large_pattern (which uses the threshold value) can even be omitted.
Final thoughts
We are always trying to improve the gt package with a mix of big features (some examples: improving rendering, adding new families of functions) and numerous tiny features (like improving existing functions, clarifying documentation, etc.). It's hoped that the things delivered in gt 0.6.0 lead to improvements in how you create and present summary tables in R. If there are features you *really* want, always feel free to:
File an issue: https://github.com/rstudio/gt/issues)
Talk about your ideas on the Discussions page: https://github.com/rstudio/gt/discussions
Learn more about the gt package here:
https://gt.rstudio.com/
Got questions? The RStudio Community site is a great place to get assistance:
https://community.rstudio.com/
Content: Rich Iannone (@riannone)
Motion Design & editing: Jesse Mostipak
Music: Nu Fornacis by Blue Dot Sessions https://app.sessions.blue/browse/track/98983
gt
rstudio
RStudio
Data Science
Machine Learning
Python
Stats
Tidyverse
Data Visualization
Data Viz
Ggplot
Coding
Server Pro
Shiny
Rmarkdown
CRAN
Interoperability
Dplyr
Forcats
Ggplot2
Tibble
Readr
Stringr
Tidyr
Purrr
Github
Data Wrangling
Tidy Data
Odbc
Plumber
Blogdown
Gt
Lazy Evaluation
Tidymodels
Statistics
Debugging
Programming Education
Rstats
Open Source
Oss
Reticulate
Gt 0.6.0
Rich Iannone
Gt Update
Sub_missing
Sub_small_vals
Sub_large_vals
Sub_zero
Tables