
What's New in {gt} 0.7.0?
gt 0.7.0 was just released. Rich Iannone, maintainer of gt, dives into the 7 new features added. For more details, ⬢ Read the blog post on gt 0.7 https://www.rstudio.com/blog/all-new-things-in-gt-0-7-0/. ⬢ Learn more about gt at https://gt.rstudio.com/. ⬢ Follow the gt twitter account, https://twitter.com/gt_package. 00:07 The new Word table output format, .docx output. 00:34 A whole new family of vector formatting functions (vec_fmt_*()) has been added. 01:03 Table presets/themes styling with the new opt_stylize() function. 01:50 The new tab_stub_indent() for superfine control over row label indentation (in the stub) 02:26 The new fmt_duration() function for formatting of time duration values. 03:32 An upgraded gtsave() that uses {webshot2}, .png output looks better. 04:14 Accessibility enhancements for HTML table outputs
image: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
Hey, this is Rich. I'm the maintainer of the gt package. 0.7 is out, so let's see what's actually in it.
Word table output format
Feature one, the new Word output table format for gt. With that, you could output a table to a Word document. And here's an example right here inside RStudio. I'm going to load up gt. I have this example table called Exhible. We can make a gt table out of that. And if you use gt save, we could output that to a Word document. We just have to use .docx in the file extension.
Vector formatting functions
Feature number two is a whole new class of vector formatting functions, and they can be used outside of gt proper. All the work that was put into the column formatting functions, like format number, format scientific. Now you get that outside of gt. Anywhere you want to use it, say for instance, inside of Quarto or R Markdown, inside a paragraph. You want to have some format numbers or our currency values, and I can have that without having to hack sign together with gt and its column formatters.
Table styling with opt_stylize()
So another new feature we have, this is feature number three, is a new opt stylize function. With that, if you have a gt table and you don't want to style it with a lot of tab options or tab style statements, you can just use opt stylize. You give it a style number, you give it a color, and gt just takes it away and stylizes your table with a nice set of colors and line styles for all the different parts of your table.
And here's an example right here. My viewer, I just ran it over this code right here, which created a table with all sorts of different locations, like summaries and footnotes and a header. You can see right here, just by using stop stylize, we get a very nice table as a result, and you can switch the color out if you really want to.
Row label indentation with tab_stub_indent()
Feature four is a new function called tab stub indent. What it allows you to do is to take row labels in the stub and indent them. Before you could not do that very easily by adding spaces or things like that. Very manual, not so easy, but with tab stub indent, you just give the rows you want to match and you just choose the indent level. You can also use increase or decrease here. It's really quite nice. And I'm just going to run this code and we see that the sizes here are indented by two tab stops, which is really nice. We selected all these with a match statement, and you can do all sorts of nice things with indentation, with tab stub indent.
Formatting durations
So again, the feature five, we have a new function called format duration. It's a formatting function and it allows you to take any value. It can be numerical values or it can be diff time values and format them as duration values. This is really quite neat. So I'm going to show you this in an example here. We have some SP 500 data.
We're doing some stuff to it and a main thing we're doing in the time past column is running format duration. So let's actually see that in a table. And we can see here that just with the default options or very default, defaulty options, we have the time past column. It's got number of days. It added the days to it, which is quite nice. And we can, you know, choose things. We can have things like narrow here and rerun the code and we get things like this. We have a narrow days designation.
So if you have complex times going in the past, this will also work. It'll break it down into different time parts and it looks really great in a table. And because we have these formatting functions in vector formatters now, this also exists as vector format duration.
Upgraded gt_save with webshot2
In feature six, we have an upgraded GT safe and it uses webshot2. It's a better webshot. It's a sequel to the webshot package. And the main thing to know there is that it doesn't use phantom JS. It uses chromote and chromote is the thing that will take the screenshot of the table. And because of all this, you get better PNG snapshots of your table and you'll just generally have a better experience because before, well, it wasn't so good. You'd have weird things like, well, it was blurry for one thing. And also certain things like bold text did not work at all, which was quite annoying for a lot of people I can imagine. But now this fixes it. New GT safe in 0.7, it just does the trick.
You'd have weird things like, well, it was blurry for one thing. And also certain things like bold text did not work at all, which was quite annoying for a lot of people I can imagine. But now this fixes it.
Accessibility improvements
In feature seven, we have accessibility improvements for screen readers. So if you use a screen reader, you'll find that tables are read more accurately, especially complex tables.
So that's what's in 0.7 of GT. Check out the blog posts on rstudio.com and also check out the new Twitter account at GT underscore package.


