Releases: rstudio/gt
v0.3.1
New features
-
We now have the
force_sign
argument in several numeric formatting functions (fmt_number()
,fmt_integer()
,fmt_scientific()
,fmt_engineering()
,fmt_percent()
,fmt_currency()
, andfmt_bytes()
). This makes it possible to force the appearance of the positive sign for positive values (#773). (#793) -
It's now possible to add padding to the column labels and heading locations in HTML tables with two new arguments added to
tab_options()
:column_labels.padding
andheading.padding
. Several options already exist for easily changing the vertical padding of certain locations, so, these additions make it possible to fully alter to the padding from top to bottom (without resorting to using CSS) (#770). (#795) -
The
whitespace
argument has been added tocell_text()
and this provides many options for making whitespace easier to handle in HTML output tables (#714). (#797)
Minor improvements and bug fixes
-
Fixed LaTeX rendering for tables that have a stub; now data row cells are correctly laid out.
-
LaTeX output tables now properly render summary rows. In addition, grand summary rows are now rendered in LaTeX outputs (previously, grand summary rows were ignored). This clears the long-standing issue in #625. (#768)
-
Titles and optional subtitles in LaTeX output tables have an improved appearance, and the underlying code was rewritten to guard against more edge cases that might lead to failing LaTeX output. (#779)
-
The
data
argument in thecols_label()
andcols_width()
functions was renamed to.data
to avoid a partial matching issue (raised in #715). (#772) -
Fixed a bug where styles may not be applied correctly to summary row cells in HTML output tables (#752). (#782)
-
Incorporated the full use of X11 color names for styling HTML tables. Now, named colors like
gray50
won't throw an error. Additionally, CSS3 colors that have no equivalent in X11 (likeCrimson
andRebeccaPurple
) will now also just work (#712). (#787) -
Fixed a bug that occurs in the following rare circumstance: when using
summary_rows()
with no stub, a new column is generated internally and given the name rowname; but this can conflict with a column that has the same name, generating duplicate column names and not erroring at that instant (#749). (#792) -
The image generation functions
local_image()
andweb_image()
are enhanced such that multiple image paths/URLs can now be handled without errors. Thanks, @primaj for the initial work on this in #738. Fixes #510. (#803) -
Fixed a bug that occurs when using a
font
with thecell_text()
along with other styles. Fixes #661 and #802. (#805) -
Implemented a fix for the situation where
tab_style()
is used along withcells_summary()
as a location and, also,row_group_order()
is used to reorder row groups. This resulted in a non-application of the style to the targeted summary cells (#812). (#814)
v0.3.0
This release focuses on improvements to two main areas:
-
Better RTF output support:
- RTF table generation is now fit for use following an extensive rewrite of internal RTF rendering functions.
- RTF table output with
gtsave(..., "<file>.rtf")
andas_rtf()
now has much more feature parity compared to HTML tables; we can now add summary rows, format table text with Markdown viafmt_markdown()
, and expect tables that look acceptable in Word and text editors that are RTF-compatible.
-
Implementation of tidyselect semantics:
- References to columns (by way of the
columns
argument in many gt functions) now better adhere to tidyselect semantics. - Instead of using
columns = vars(a, b)
, we now usecolumns = c(a, b)
(columns = c("a", "b")
also works, and this type of expression always has been an option in gt). - Other tidyselect idioms should also work; things like using
where()
to target columns (e.g.,gt(exibble) %>% cols_hide(columns = where(is.numeric))
will hide all numeric columns) and negation (e.g.,columns = -c(a, b)
) function as expected.
- References to columns (by way of the
Breaking changes and deprecations
-
Column labels subordinate to column spanner labels had their alignment forced to be
"center"
but now there is no specialized alignment of column labels under spanners. Should you need the old behavior,tab_style()
can be used along withcell_text(align = "center")
for all columns that live under spanners. (#662) -
The automatic alignment of integer values has been changed from
"center"
to"right"
. To correct for this, usetab_style()
withcell_text(align = "center")
for all affected columns. (#662) -
As part of the tidyselect changes made in this release, using
columns = TRUE
(to mean that all columns should be considered) has now been replaced withcolumns = everything()
. Using the former will result in a warning message. (#718) -
While
vars()
is still reexported in gt, its use with thecolumns
argument (present in a large number of functions) is deprecated and a warning message will appear if it is used. In a later release, it can be expected thatvars()
will no longer be reexported. (#718) -
The
others_label
argument oftab_row_group()
is deprecated since it was confusing to use. To specify a default label for row groups, the course of action is now to usetab_options(row_group.default_label = <label>)
. (#699)
New features
-
RTF table output via
gtsave(..., "<file>.rtf")
andas_rtf()
should produce more robust tables (allowing use ofsummary_rows()
,fmt_markdown()
, etc.). And tables generated as RTF can now take advantage ofcols_width()
for flexible modifications of column widths. (#638 and #696) -
All functions with a
columns
argument can now take advantage of gt's full adherence to tidyselect semantics (usecolumns = c(a, b)
orcolumns = c("a", "b")
instead ofcolumns = vars(a, b)
). (#718) -
New location helper functions have been added to make it possible to style more locations and add footnotes to once inaccessible locations; these are
cells_stub_summary()
,cells_stub_grand_summary()
,cells_footnotes()
, andcells_source_notes()
. Note that footnotes cannot be declared with the latter two functions. (#737) -
The
cols_unhide()
function has been added as a complement to thecols_hide()
function. This is useful when provided thegt_tbl
object without the source data and code to recreate it and there are hidden columns that should be made visible. (#710) -
The new formatting function
fmt_bytes()
helps you to transform numerical values to byte sizes with human readable units. (#750) -
A new column merging function,
cols_merge_n_pct()
, works to merge a count column and a percentage column together. This function will automatically hide thecol_pct
column by default (but that can be changed by settingautohide = FALSE
). (#683) -
Added the
caption
argument togt()
. This brings caption support to gt tables in R Markdown and bookdown documents. (#689)
Minor improvements
-
The
accounting
option is now available in thefmt_percent()
andfmt_number()
formatting functions (previously it was only present infmt_currency()
). (#756) -
In RTF documents generated through
as_rtf()
andgtsave(..., filename = "<file>.rtf")
, there is now apage_numbering
option for adding page numbers to either the"footer"
or the"header"
areas (the default is"none"
). (#755) -
tab_spanner_delim()
gained asplit
argument to govern whether delimiter splitting should occur at the"first"
or"last"
instance ofdelim
. For example, if the column name"a.b.c"
is present andsplit = "first"
then the spanner column label is"a"
and the associated column label will be"b.c"
; shouldsplit = "last"
then the spanner and column will have"a.b"
and"c"
labels. (#699) -
Added
id
as an argument totab_spanner()
andtab_row_group()
, which is useful for later access to these locations (especially when spanner or row group labels are complicated). (#665, #699) -
HTML table generation is much faster due to efforts to optimize HTML code generation in the building/rendering phase. (#664)
Bug fixes
-
When getting the HTML text for gt table with
as_raw_html(..., inline_css = FALSE)
, the<style>
tag content is no longer omitted. (#718) -
Fixed two bugs in
tab_row_group()
: (1) incorrect reordering of rows (Issue #717), and (2) spurious warnings with multiple calls (Issue #675). (#699) -
The
tab_spanner_delim()
withgather = TRUE
did not work reliably (Issue #626) but was fixed along with other work done to overhaul the function. (#665) -
Correction made to the representation of the
PEN
(Peruvian Nuevo Sol) currency. (#663) -
Fix for
gtsave()
when saving an image and specifying apath
value. (#592)
v0.2.2
New features
-
The new
opt_table_font()
function makes it possible to define a custom font for the entire gt table. The standard fallback fonts are still set by default but the font defined here will take precedence. You could still have different fonts in select locations in the table, and for that you would need to usetab_style()
in conjunction with thecell_text()
helper function. The newgoogle_font()
helper function provides an option for supplying a font available at the Google Fonts service (this is in addition to using system fonts in thefont
argument). Using theinfo_google_fonts()
function will provide a table with a set of helpful font recommendations from the Google Fonts catalog. The newdefault_fonts()
functions provides a helpful vector of system fallback fonts which works well when defining a vector of fonts. (#591) -
The new
opt_css()
function makes allows for the addition of custom CSS to a gt table. This CSS will be added after the compiled CSS that gt generates automatically when thegt_tbl
object is transformed to an HTML output table. You can supplycss
as a vector of lines or as a single string. Thecss()
function has been re-exported from htmltools to make it easier to build CSS style declarations. (Also #591) -
Setting the widths of table columns is now easier and more dependable with
cols_width()
. Widths can be expressed in units of pixels (easily set by use of thepx()
helper function), as percentages (where thepct()
helper function is useful), or a mixture of the two. The function takes into consideration whether an overall table width has been provided withtab_options(table.width = ...)
. Providing pixel widths for all columns serves to override any table width defined (yielding columns with the exact widths specified). (#561) -
There are new options for numeric formatting: (1) using significant figures (with
n_sigfig
infmt_number
), and (2) the ability to retain/drop trailing decimal marks (withdrop_trailing_dec_mark
infmt_number()
,fmt_percent()
, andfmt_currency()
). Thank you @drolejoel for the suggestion in #535! (#546). -
The new
scale_values
argument forfmt_percent()
makes it easy to use values that are already scaled (and just require the percent mark). Thank you @djohn215 for the suggestion in #559. (#565) -
Font weights expressed as numeric values (e.g.,
400
,600
, etc.) incell_text()
'sweight
argument now works properly. (#591)
Minor improvements and bug fixes
v0.2.1
v0.2.0.5
- New package with 80 exported functions for building display tables