v0.10.0
Nanoplots
-
We can now add in little plots called nanoplots to a gt table (#299, #515). (#1431, #1439, #1445, #1453, #1458, #1459, #1461, #1462)
-
The function
cols_nanoplot()
adds a new column that contains the plots. The data can be obtained from one or more columns in the table. A helper function callednanoplot_options()
allows for altering the composition and styling of the nanoplots in the new column. -
There are two basic types of nanoplots available:
"line"
and"bar"
. A line plot shows individual data points and has smooth connecting lines between them to allow for easier scanning of values. You can opt for straight-line connections between data points, or, no connections at all (it's up to you). The data you feed into a line plot can consist of a single vector of values (resulting in equally-spaced y values), or, you can supply two vectors representative of x and y. -
A bar plot is built a little bit differently. The focus is on evenly-spaced bars (requiring a single vector of values) that project from a zero line, clearly showing the difference between positive and negative values.
-
By default, any type of nanoplot will have basic interactivity. One can hover over the data points and vertical guides will display values ascribed to each. A guide on the left-hand side of the plot area will display the minimal and maximal y values on hover.
Other great new features
-
Brand new rows can be added to a gt table with the new
rows_add()
function. The user can supply the new row data through name value pairs. You have control over where they are placed by way of the.before
and.after
arguments (new rows are added to the bottom of the table by default). You can also add empty (i.e., allNA
) rows with the.n_empty
option (#698). (#1323) -
To complement
rows_add()
, thecols_add()
function was added. New columns can indeed be added to a gt table with this function, which has an interface close to that ofdplyr::mutate()
. (#1367) -
You can now use an empty table as the starting point for a gt table. This can be used in conjunction with
cols_add()
androws_add()
to build a table piece-by-piece in specific workflows/settings. What constitutes empty tables can be any of:0 x 0
tables,0 x n
tables (no rows, some columns), orn x 0
tables (some rows, no columns; treated the same as0 x 0
tables). (#1376) -
There is now a way to better express measurement units and we do this in gt with something called units notation. With an intuitive and easy-to-learn syntax, gt will ensure that any measurement units are formatted correctly no matter what the output type is. We can format units in the table body with
fmt_units()
, we can attach units to column labels withcols_units()
, and we can integrate units notation in the already-availablecols_label()
andtab_spanner()
functions (#417, #533). (#1357, #1426, #1446) -
A very useful new helper function,
from_column()
, has been added so you can fetch values (for compatible arguments) from a column in the input table. For example, if you are usingfmt_scientific()
and the number of significant figures should vary across the values to be formatted, a column containing those values for then_sigfig
argument can be referenced byfrom_column()
. (#1392, #1393, #1395, #1396, #1399, #1403) -
With the new
fmt_icon()
function we are able to add icons from the Font Awesome icon library. It works in a way that's similar tofmt_flag()
, in that identifiers in the formatted cells are transformed in-place to SVG-based icons. (#1413) -
The
info_icons()
andinfo_flags()
functions have been added to help people know about the valid codes for flags and for icons (when usingfmt_icon()
andfmt_flag()
). (#1421) -
We added the
extract_body()
function, which lets you pull out a data frame associated with the body cells. Importantly, this extraction can happen at different stages of the table build (e.g.,"init"
,"text_transformed"
, etc.), allowing a user to have access to a table of formatted body cells for different applications (such as verification of formatting, debugging new formatting functions, etc.) (#1441). (#1449) -
Interactive HTML tables (usually generated through use of
opt_interactive()
) can now use localized labels/controls. So when using any of the 574 supported locales in gt, an interactive table will be fully translated to the language of the locale (#1308). (#1389) -
The
illness
andconstants
datasets were added. Both datasets have aunits
column and this is useful for making examples with thefmt_units()
function. (#1357)
Improvements to the Word output format
-
Processing to Word output now escapes HTML in more places (#1378). (#1303)
-
The Word output format now uses the
side
argument present insummary_rows()
andgrand_summary_rows()
to place the new summary rows either the top or bottom of the row group (withsummary_rows()
) or table as a whole (withgrand_summary_rows()
). (#1325) -
Tables rendered as Word output can now handle the specific case where a table with summary rows doesn't have row names. (#1325)
-
Summary rows in Word output tables can now be placed at the top or bottom of a group (or at the top or bottom of the table). (#1402)
-
Word output tables can now contain images. This entails compatibility with the
fmt_image()
function, and, images (local and remote) can be inserted through Markdown (#1272). (#1273)
Documentation enhancements
-
The gt website has been updated with a slightly different look; section names have been updated for consistency (#1419). (#1287, #1340, #1341, #1444)
-
We've improved the formatting of arguments in the documentation so that they all have short titles and descriptions regarding expected inputs and default values. This looks great both in the internal R help pages and in the pkgdown-generated website (#1290). (#1338)
-
Several small documentation updates were made, with an emphasis on improving examples (#1304, #1349, #1369). (#1293, #1316, #1324, #1329, #1330, #1331, #1334, #1381, #1383, #1395, #1404, #1442, #1454)
Minor improvements and bug fixes
-
The
tab_spanner_delim()
function was given alimit
argument so that splitting from a particular side can stop early and precisely. (#1328) -
The
width
argument was added tofmt_image()
. With this change you can variously set the width, the height, or both. -
Significant figures support has been added to the
fmt_scientific()
andvec_fmt_scientific()
functions; there is a newn_sigfig
argument in both. (#1411) -
The
cols_merge_range()
function now has alocale
argument. Range patterns across locales are different (can involve the use of a single hyphen, en dash, em dash, tilde, etc.) and so it does make sense to follow the convention of a locale if provided (#158). (#1423) -
The
fmt_url()
function now has a few more options for adding anchor tag attributes ("target"
,"rel"
,"referrerpolicy"
, and"hreflang"
). Thanks @elipousson for the work on this! (#1428). (#1452) -
We now have rudimentary support for defining column widths for LaTeX output tables (with
cols_width()
). This accepts length values in 'px' which and automatic conversion to 'pt' values is performed to maximize compatibility with different LaTeX flavors (#634, #851, #1417). (#1371, #1450) -
It's now possible to use background fill colors and perform text coloring and emboldened/italicized text within the body cells of LaTeX tables. This is commonly performed through the use of
tab_style()
anddata_color()
(#84, #869). (#1352) -
The
gtsave()
function now works withgt_group
objects (usually generated throughgt_split()
orgt_group()
) (#1354). (#1365) -
All
gt_group
objects can now be printed using R Markdown or Quarto (#1286). (#1332) -
When using
fmt_currency()
with a locale value set, gt will now use that to automatically select the locale's default currency. While some countries can have multiple currencies, we opt for the most-widely used currency (users could alternatively specify the currency code andinfo_currencies()
contains all supported currencies used in the package) (#1346). (#1347) -
The
columns
argument incols_hide()
andcols_unhide()
can now acceptNULL
(i.e., no columns resolved). These functions will no longer error in such a case (#1342). (#1343) -
The
countrypops
dataset was updated with recent (as of August 2023) World Bank data that revises population estimates and brings the final year up to 2022. All examples, tests, and articles using the dataset were also updated. (#1410) -
A few refinements were made to some of the system font stacks defined in
system_fonts()
. (#1447) -
The Databricks notebook environment is now detected by gt, so tables will now be automatically displayed without having to call extra printing functions. (#1427)
-
Display issues with scientific and engineering notation formatting (lack of dropping trailing zeros, as promised with the
drop_trailing_zeros
argument) were fixed. Part of the fix involves adding thedrop_trailing_dec_mark
argument to the four functionsfmt_scientific()
,fmt_engineering()
,vec_fmt_scientific()
andvec_fmt_engineering()
. (#1380) -
Fixed an incorrect country code reference for the Netherlands that would cause an incorrect flag to appear when using
fmt_flag()
. (#1319) -
Many new flags were added to
fmt_flag()
(#1333, #1335). (#1336) -
In some cases, there was incorrect rounding of duration values when using
fmt_duration()
. This is now fixed, thanks to @rcannood (#1374). (#1375) -
Fixed an issue with
cols_label_with()
where column names wouldn't be relabeled if the resolved columns were only a subset of the total columns available. (#1326) -
Fixed a LaTeX bug where some characters following a
\midrule
would corrupt the table (#145, #391, #1107, #1182). (#1390) -
Provided a rendering fallback for HTML tables rendered in Quarto where the combination of
fmt_markdown()
andtab_options(quarto.disable_processing = TRUE)
would incorrectly result in empty cells. (#1455) -
A issue associated with a lack of HTML formatting within interactive tables has been fixed (#1299, #1370, #1384, #1443). (#1388)
-
Many user-facing error messages have been enhanced using the latest features from the cli package. (#1337, thanks @olivroy!)
-
Unit tests can now be successfully run on Linux flavors that don't have the
locale
utility (#1214). (#1350, thanks @bastistician!) -
If ever the 'undetermined' (
"und"
) locale is used, it is automatically mapped to the"en"
locale. (#1394) -
Many unit tests were added for much increased test coverage and many more were modified to increase the speed of running the test suite. (#1291, #1294, #1298, #1350, #1412)
-
Added utility functions to extract all examples for regularly building a Quarto website (to do integration testing). (#1344)