Skip to content

Commit 0acc7fb

Browse files
authored
Merge pull request #1127 from rstudio/v0.8.0-rc
Release gt v0.8.0
2 parents c8d24e3 + 0063ec9 commit 0acc7fb

File tree

6 files changed

+84
-35
lines changed

6 files changed

+84
-35
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Type: Package
22
Package: gt
3-
Version: 0.7.0.9000
3+
Version: 0.8.0
44
Title: Easily Create Presentation-Ready Display Tables
55
Description: Build display tables from tabular data with an easy-to-use set of
66
functions. With its progressive approach, we can construct display tables

NEWS.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,54 @@
1-
# gt (development version)
1+
# gt 0.8.0
2+
3+
## New features
4+
5+
* The new function `sub_values()` is here for subbing in arbitrary text in body cells, based on value, a regex, or a specialized function. It's like a supercharged find-and-replace for your **gt** table (#703). (#1066)
6+
7+
* We want the setting of styles to be as easy as possible so, to that end, we've added a helpful new function: `tab_style_body()`. This function is a bit like `sub_values()` and a bit like `tab_style()`. The idea is that basic style attributes can be set based on values in the table body. We can target body cells though value, regex, and custom matching rules, and, apply styles to them and their surrounding context (e.g., styling an entire row or column wherein the match is found). The help file at `?tab_style_body` provides copious examples w/ eye catching visuals (#863). (#1108)
8+
9+
* The `fmt_date()`, `fmt_time()`, and `fmt_datetime()` functions have been improved so much, I don't even know where to begin. The `fmt_datetime()` function has an enhanced `format` argument that accepts *CLDR*-style formatting patterns (much more powerful and flexible than the `strptime()` patterns). The `fmt_datetime()` function will detect the pattern type given in `format`. The `date_style` and `time_style` arguments still exist but have been extended to accept more style keywords. There is now the concept of flexible date and time formats that are locale-aware (the `locale` argument is new to these functions). The `info_date_style()` and `info_time_style()` functions have been enhanced to give you display tables will all the style possibilities. All of this goodness extends to the `vec_fmt_*()` variants (`vec_fmt_date()`, `vec_fmt_time()`, and `vec_fmt_datetime()`). The documentation for all of this has been overhauled and provides many explanations and examples for your edification (#531, #1052). (#1053)
10+
11+
* We can now have decimal alignment for numeric values and this made possible with the new `cols_align_decimal()` function. The function ensures that columns targeted are right-aligned, that accounting notation is supported, and that footnote marks don't interfere (#139, #144, #560, #673). (#1058, #1092; assist by the inimitable @steveputman!)
12+
13+
* We can easily add a caption to a **gt** table (or replace an existing one) with the new and convenient `tab_caption()` function (#1048). (#1051, thank you @billdenney!)
14+
15+
* So you've got a **gt** table and you want a value or two from that table to appear elsewhere in your R Markdown or Quarto document. Previously, you had to recreate it in some way but now you can use `extract_cells()`! That function will extract a vector of cell data from a `gt_tbl` object. The output vector will have the cell data formatted in the same way as the table. (#1045, #1047)
16+
17+
* The `as_raw_html()` function is useful for generating an HTML string for table-in-HTML-email situations and for HTML embedding purposes (with that `inline_css = TRUE` option). While the CSS-inlining has been mostly fine, it had two major problems: (1) it was *slow*, and (2) the underlying R code was so underpowered that it just couldn't keep up with changes to our SCSS styles. This is now solved by integrating a package that uses the *juice* JS library (we call it **juicyjuice**!). This solution is far more performant and correct (#455, #540, #837, #858, #915, #1093). (#1114)
18+
19+
* There's now padding around an HTML table! And you can even control the left/right (`container.padding.x`) and top/bottom (`container.padding.y`) padding values through `tab_options()`! This is very helpful since tables were way too close to paragraphs of text in rendered HTML documents produced by R Markdown and Quarto (#590, #1105). (#1116)
20+
21+
* The table stub can now freely merge with other columns using any of the `cols_merge*()` collection of functions. This is great if you want to independently format the stub and other columns and then bring them together in interesting ways. (#1122)
22+
23+
* We've added the ability to treat columns containing row names or group names as Markdown text. This provides the `process_md` argument in the `gt()` function. If this option is taken (example below) then the supplied names will be treated to ensure that there are unique IDs for later targeting (for `tab_style()`, `tab_footnote()`, etc.) (#694). (#1097)
24+
25+
```r
26+
dplyr::tibble(x = c("**a**", "b", "*c*"), y = c("*A*", "*B*", "*B*"), z = 1:3) %>%
27+
gt(rowname_col = "x", groupname_col = "y", process_md = TRUE)
28+
```
29+
30+
* If you find yourself not knowing the ID values of certain cells in the table (sometimes necessary for adding footnotes, styles, etc.) the new `tab_info()` function can help! Use that with a **gt** object and you'll get an informative table that summarizes all of the table's ID values and their associated labels (#1102). (#1104)
31+
32+
* Much of **gt** is about adding things to a table but what about doing the opposite (taking things away)? The new family of `rm_*()` functions (`rm_header()`, `rm_stubhead()`, `rm_spanners()`, `rm_footnotes()`, `rm_source_notes()`, and `rm_caption()`) let us safely remove parts of a **gt** table. This can be advantageous in those instances where one might obtain a **gt** table though other means (like from another pkg) but prefer to excise some parts of it (#790, #1005). (#1073)
33+
34+
* The table stub column can now have its contents formatted with any of the `fmt_*()` functions. We also added the `stub()` helper function to help select the stub column (#747). (#1038)
35+
36+
* The new formatter function `fmt_roman()` lets us easily format numbers to Roman numerals (either as uppercase or lowercase letters). The `vec_fmt_roman()` vector-formatting function was also introduced here. (#1035)
37+
38+
* The `data_color()` function allows us to color the background of cells based on data, and **gt** smartly chooses a text color that provides the most contrast between text and background. We wanted to improve that feature so now `data_color()` has a `contrast_algo` argument that allows us to choose between two color contrast algorithms: `"apca"` (*Accessible Perceptual Contrast Algorithm*; new, and the default now) and `"wcag"` (*Web Content Accessibility Guidelines*). (#1062)
39+
40+
* The accessibility of structurally-complicated **gt** tables (i.e., multi-level headings, irregular headers, row groups, etc.) was addressed by work that follows the W3C WAI (*Web Accessibility Initiative*) guidance. Now, screen readers can better describe **gt** tables with such complex structures (#926). (#988, thanks @jooyoungseo!)
241

342
## Minor improvements and bug fixes
443

5-
* `docx` output format is now correctly detected in R Markdown and Quarto (#1040). (#1084)
44+
* The `docx` output format is now better detected in R Markdown and Quarto (#1040). (#1084, thanks @cderv!)
645

746
* Replaced all `match.arg()` calls with **rlang*'s `match_arg()` for better error output (#672). (#1099, thanks @mojister!)
847

48+
* Project website improvements; we now have a doublet of sites: (1) https://gt.rstudio.com and (2) https://gt.rstudio.com/dev (#1074, thanks @ddsjoberg!)
49+
50+
* The dependency on the **stringr** package has been removed by replacing the remaining **stringr**-based function calls in the package with base-R equivalents. (#1043)
51+
952
# gt 0.7.0
1053

1154
## New features

R/substitution.R

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -632,16 +632,26 @@ check_sub_fn_sign <- function(sign) {
632632
#' Substitute targeted values in the table body
633633
#'
634634
#' @description
635-
#' Should you need to replace specific cell values with something else, the
636-
#' `sub_values()` function is a good choice.
637-
#'
638-
#' @details
639-
#' Targeting of values is done through `columns` and additionally by `rows` (if
640-
#' nothing is provided for `rows` then entire columns are selected). Conditional
641-
#' formatting is possible by providing a conditional expression to the `rows`
642-
#' argument. See the Arguments section for more information on this.
635+
#' Should you need to replace specific cell values with custom text, the
636+
#' `sub_values()` function can be good choice. We can target cells for
637+
#' replacement though value, regex, and custom matching rules.
643638
#'
644639
#' @inheritParams fmt_number
640+
#' @param columns Optional columns for constraining the targeting process.
641+
#' Providing [everything()] (the default) results in cells in all `columns`
642+
#' being targeting (this can be limited by `rows` however). Can either be a
643+
#' series of column names provided in [c()], a vector of column indices, or a
644+
#' helper function focused on selections. The select helper functions are:
645+
#' [starts_with()], [ends_with()], [contains()], [matches()], [one_of()],
646+
#' [num_range()], and [everything()].
647+
#' @param rows Optional rows for constraining the targeting process. Providing
648+
#' [everything()] (the default) results in all rows in `columns` being
649+
#' targeted. Alternatively, we can supply a vector of row captions within
650+
#' [c()], a vector of row indices, or a helper function focused on selections.
651+
#' The select helper functions are: [starts_with()], [ends_with()],
652+
#' [contains()], [matches()], [one_of()], [num_range()], and [everything()].
653+
#' We can also use expressions to filter down to the rows we need (e.g.,
654+
#' `[colname_1] > 100 & [colname_2] < 50`).
645655
#' @param values The specific value or values that should be replaced with a
646656
#' `replacement` value. If `pattern` is also supplied then `values` will be
647657
#' ignored.

R/tab_remove.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,7 @@ rm_source_notes <- function(
615615
data
616616
}
617617

618-
619-
#' Remove the stubhead label
618+
#' Remove the table caption
620619
#'
621620
#' @description
622621
#' We can easily remove the caption text from a **gt** table with

man/rm_caption.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sub_values.Rd

Lines changed: 18 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)