From cfc8a4af3a78fb6e37b3f80d184337d074bba57a Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 7 Jun 2024 14:19:33 -0400 Subject: [PATCH 1/3] Tweaks to docs --- NEWS.md | 2 +- R/format_data.R | 13 +++++++------ R/info_tables.R | 3 ++- R/modify_columns.R | 27 +++++++++++++-------------- R/rows_add.R | 2 +- R/tab_create_modify.R | 7 +++---- R/topics.R | 1 + 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/NEWS.md b/NEWS.md index 280cf8aef4..31c3001639 100644 --- a/NEWS.md +++ b/NEWS.md @@ -301,7 +301,7 @@ * The `docx` output format is now better detected in R Markdown and Quarto (#1040). (#1084, thanks @cderv!) -* Replaced all `match.arg()` calls with **rlang**'s `match_arg()` for better error output (#672). (#1099, thanks @mojister!) +* Replaced all `match.arg()` calls with `rlang::arg_match()` for better error output (#672). (#1099, thanks @mojister!) * 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!) diff --git a/R/format_data.R b/R/format_data.R index 343f79e89c..32173a9bac 100644 --- a/R/format_data.R +++ b/R/format_data.R @@ -8050,7 +8050,9 @@ extract_duration_pattern <- function( } #' Format column data containing bin/interval information - +#' +#' @description +#' #' When using `cut()` (or other functions that use it in some way) #' you get bins that can look like this: `"(0,10]"`, `"(10,15]"`, `"(15,20]"`, #' `"(20,40]"`. This interval notation expresses the lower and upper limits of @@ -12838,11 +12840,10 @@ fmt_country <- function( #' Depending on which train services are offered at the subset of stations, #' *Font Awesome* icon names will be applied to cells where the different #' services exist (the specific names are `"train-subway"`, `"train"`, and -#' `"train-tram"`). With **tidyr**'s `unite()` function, those icon names -#' can be converged into a single column (`services`) with the `NA` values -#' removed. Since the names correspond to icons and they are in the correct -#' format (separated by commas), they can be formatted as *Font Awesome* icons -#' with `fmt_icon()`. +#' `"train-tram"`). With `tidyr::unite()`, those icon names can be converged +#' into a single column (`services`) with the `NA` values removed. Since the +#' names correspond to icons and they are in the correct format (separated by +#' commas), they can be formatted as *Font Awesome* icons with `fmt_icon()`. #' #' ```r #' metro |> diff --git a/R/info_tables.R b/R/info_tables.R index 054de61acb..4e003fe6ef 100644 --- a/R/info_tables.R +++ b/R/info_tables.R @@ -796,7 +796,8 @@ info_flags <- function() { #' from the **fontawesome** package). Because there is a very large number of #' icons available to use in *Font Awesome*, `info_icons()` can be used to #' provide us with a table that lists all the icons along with their short and -#' full names (either can be used with [fmt_icon()]). +#' full names (either can be used with [fmt_icon()]). It also contains +#' acceptable codes for [fmt_country()] #' #' @return An object of class `gt_tbl`. #' diff --git a/R/modify_columns.R b/R/modify_columns.R index 70beeeef2d..efd4e87abf 100644 --- a/R/modify_columns.R +++ b/R/modify_columns.R @@ -858,7 +858,7 @@ cols_width <- function( #' The [`illness`] dataset has units within the `units` column. They're #' formatted in just the right way for **gt** too. Let's do some text #' manipulation through `dplyr::mutate()` and some pivoting with -#' **tidyr**'s `pivot_longer()` and `pivot_wider()` in order to include the +#' `tidyr::pivot_longer()` and `tidyr::pivot_wider()` in order to include the #' units as part of the column names in the reworked table. These column names #' are in a format where the units are included within `"{{"`/`"}}"`, so, we can #' use `cols_label()` with the `.process_units = TRUE` option to register the @@ -1611,18 +1611,17 @@ cols_units <- function( #' #' @description #' -#' We can add new columns to a table with the `cols_add()` function and it works -#' quite a bit like the **dplyr** `mutate()` function. The idea is that you -#' supply name-value pairs where the name is the new column name and the value -#' part describes the data that will go into the column. The latter can: -#' (1) be a vector where the length of the number of rows in the data table, -#' (2) be a single value (which will be repeated all the way down), or (3) -#' involve other columns in the table (as they represent vectors of the correct -#' length). The new columns are added to the end of the column series by default -#' but can instead be added internally by using either the `.before` or `.after` -#' arguments. If entirely empty (i.e., all `NA`) columns need to be added, you -#' can use any of the `NA` types (e.g., `NA`, `NA_character_`, `NA_real_`, etc.) -#' for such columns. +#' We can add new columns to a table with `cols_add()` and it works quite a bit +#' like `dplyr::mutate()` does. The idea is that you supply name-value pairs +#' where the name is the new column name and the value part describes the data +#' that will go into the column. The latter can: (1) be a vector where the +#' length of the number of rows in the data table, (2) be a single value +#' (which will be repeated all the way down), or (3) involve other columns in +#' the table (as they represent vectors of the correct length). The new columns +#' are added to the end of the column series by default but can instead be added +#' internally by using either the `.before` or `.after` arguments. If entirely +#' empty (i.e., all `NA`) columns need to be added, you can use any of the `NA` +#' types (e.g., `NA`, `NA_character_`, `NA_real_`, etc.) for such columns. #' #' @inheritParams fmt_number #' @@ -2604,7 +2603,7 @@ cols_add <- function( #' pizza analytics). We also have the sell price for a pizza, and that'll serve #' as the *y* values. The pizzas belong to four different groups (in the `type` #' column) and we'll group by that and create value streams with -#' `paste(..., collapse = ",")` in the **dplyr** summarize call. With two value +#' `paste(..., collapse = ",")` inside the `dplyr::summarize()` call. With two value #' streams in each row (having the same number of values) we can now make a #' **gt** table with nanoplots. #' diff --git a/R/rows_add.R b/R/rows_add.R index ae7b7ccc1c..b4819fb0f8 100644 --- a/R/rows_add.R +++ b/R/rows_add.R @@ -214,7 +214,7 @@ #' Another application is starting from nothing (really just the definition of #' columns) and building up a table using several invocations of `rows_add()`. #' This might be useful in interactive or programmatic applications. Here's an -#' example where two columns are defined with **dplyr**'s `tibble()` function +#' example where two columns are defined with `dplyr::tibble()` #' (and no rows are present initially); with two calls of `rows_add()`, two #' separate rows are added. #' diff --git a/R/tab_create_modify.R b/R/tab_create_modify.R index d1396ce6ec..14a0677d83 100644 --- a/R/tab_create_modify.R +++ b/R/tab_create_modify.R @@ -1064,10 +1064,9 @@ resolve_spanned_column_names <- function( #' }} #' #' With a summarized, filtered, and pivoted version of the [`pizzaplace`] -#' dataset, we can create another **gt** table and then use the -#' `tab_spanner_delim()` function with the same delimiter/separator that was -#' used in the **tidyr** `pivot_wider()` call. We can also process the generated -#' column labels with [cols_label_with()]. +#' dataset, we can create another **gt** table and then use `tab_spanner_delim()` +#' with the delimiter/separator also used in `tidyr::pivot_wider()`. We can also +#' process the generated column labels with [cols_label_with()]. #' #' ```r #' pizzaplace |> diff --git a/R/topics.R b/R/topics.R index 5235293afc..48a4ade07b 100644 --- a/R/topics.R +++ b/R/topics.R @@ -55,4 +55,5 @@ #' * [text_case_match()] #' #' These functions contain more example of usage. +#' @keywords internal NULL From 34c7b369db6b7b49933ceed3ecfa6f64584b506c Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 7 Jun 2024 14:19:57 -0400 Subject: [PATCH 2/3] Fixes in `_pkgdown.yml` --- pkgdown/_pkgdown.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 9a620c7a10..4056a088ef 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -34,10 +34,10 @@ reference: All **gt** tables begin with a call to `gt()`, where we would supply the input data table (data frame or tibble) and some basic options for creating a stub (`rowname_col`) and row groups (`groupname_col`). We - can also introduce a grouped tibble (via **dplyr**'s `group_by()`) for - more precise divisions of rows into row groups. The `gt_preview()` - function is great for getting a nicely-formatted preview of a data - table (defaulting to the first 5 rows and the last row). + can also introduce a grouped tibble (via `dplyr::group_by()`) for + more precise divisions of rows into row groups. `gt_preview()` + is great for getting a nicely-formatted preview of a data table + (defaulting to the first 5 rows and the last row). contents: - gt - gt_preview @@ -185,13 +185,13 @@ reference: desc: > An assortment of helper functions is available in the **gt** package. The various `cells_*()` functions are used for targeting cells with the - `locations` argument in the `tab_footnote()`, `tab_style()`, and - `text_transform()` functions. The `cell_*()` functions are used - exclusively with `tab_style()`'s `style` argument. The `px()` & - `pct()` functions are useful there for specifying units in pixels or - percentages. The `md()` and `html()` helpers can used be during label - creation with the `tab_header()`, `tab_footnote()`, `tab_spanner()`, - `tab_stubhead_label()`, and `tab_source_note()` functions. + `locations` argument of `tab_footnote()`, `tab_style()`, and + `text_transform()`, `text_case_match()`, and `text_case_when()`. + The `cell_*()` functions are used exclusively with `tab_style()`'s `style` + argument. `px()` & `pct()` are useful there for specifying + units in pixels or percentages. The `md()` and `html()` helpers can used + be during label creation with `tab_header()`, `tab_footnote()`, + `tab_spanner()`, `tab_stubhead()`, and `tab_source_note()`. contents: - md - html From 157eb7ed2c0fca0c7bca884d7be42a0ac8d8590f Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 7 Jun 2024 14:21:13 -0400 Subject: [PATCH 3/3] Update man with roxygen --- man/cols_add.Rd | 23 +++++++++++------------ man/cols_label.Rd | 2 +- man/cols_nanoplot.Rd | 2 +- man/fmt_bins.Rd | 12 +----------- man/fmt_icon.Rd | 9 ++++----- man/info_icons.Rd | 3 ++- man/location-helper.Rd | 1 + man/rows_add.Rd | 2 +- man/tab_spanner_delim.Rd | 7 +++---- 9 files changed, 25 insertions(+), 36 deletions(-) diff --git a/man/cols_add.Rd b/man/cols_add.Rd index dcf03ef75a..65556a4bb2 100644 --- a/man/cols_add.Rd +++ b/man/cols_add.Rd @@ -44,18 +44,17 @@ of the column series.} An object of class \code{gt_tbl}. } \description{ -We can add new columns to a table with the \code{cols_add()} function and it works -quite a bit like the \strong{dplyr} \code{mutate()} function. The idea is that you -supply name-value pairs where the name is the new column name and the value -part describes the data that will go into the column. The latter can: -(1) be a vector where the length of the number of rows in the data table, -(2) be a single value (which will be repeated all the way down), or (3) -involve other columns in the table (as they represent vectors of the correct -length). The new columns are added to the end of the column series by default -but can instead be added internally by using either the \code{.before} or \code{.after} -arguments. If entirely empty (i.e., all \code{NA}) columns need to be added, you -can use any of the \code{NA} types (e.g., \code{NA}, \code{NA_character_}, \code{NA_real_}, etc.) -for such columns. +We can add new columns to a table with \code{cols_add()} and it works quite a bit +like \code{dplyr::mutate()} does. The idea is that you supply name-value pairs +where the name is the new column name and the value part describes the data +that will go into the column. The latter can: (1) be a vector where the +length of the number of rows in the data table, (2) be a single value +(which will be repeated all the way down), or (3) involve other columns in +the table (as they represent vectors of the correct length). The new columns +are added to the end of the column series by default but can instead be added +internally by using either the \code{.before} or \code{.after} arguments. If entirely +empty (i.e., all \code{NA}) columns need to be added, you can use any of the \code{NA} +types (e.g., \code{NA}, \code{NA_character_}, \code{NA_real_}, etc.) for such columns. } \section{Targeting the column for insertion with \code{.before} or \code{.after}}{ diff --git a/man/cols_label.Rd b/man/cols_label.Rd index ceb6ca8e57..6e8caebaa7 100644 --- a/man/cols_label.Rd +++ b/man/cols_label.Rd @@ -266,7 +266,7 @@ incorporates unit notation text (within \code{"{{"}/\code{"}}"}). The \code{\link{illness}} dataset has units within the \code{units} column. They're formatted in just the right way for \strong{gt} too. Let's do some text manipulation through \code{dplyr::mutate()} and some pivoting with -\strong{tidyr}'s \code{pivot_longer()} and \code{pivot_wider()} in order to include the +\code{tidyr::pivot_longer()} and \code{tidyr::pivot_wider()} in order to include the units as part of the column names in the reworked table. These column names are in a format where the units are included within \code{"{{"}/\code{"}}"}, so, we can use \code{cols_label()} with the \code{.process_units = TRUE} option to register the diff --git a/man/cols_nanoplot.Rd b/man/cols_nanoplot.Rd index 9ba3636de6..e87cbb2e69 100644 --- a/man/cols_nanoplot.Rd +++ b/man/cols_nanoplot.Rd @@ -534,7 +534,7 @@ time instants: the second of the day that a pizza was sold (this is true pizza analytics). We also have the sell price for a pizza, and that'll serve as the \emph{y} values. The pizzas belong to four different groups (in the \code{type} column) and we'll group by that and create value streams with -\code{paste(..., collapse = ",")} in the \strong{dplyr} summarize call. With two value +\code{paste(..., collapse = ",")} inside the \code{dplyr::summarize()} call. With two value streams in each row (having the same number of values) we can now make a \strong{gt} table with nanoplots. diff --git a/man/fmt_bins.Rd b/man/fmt_bins.Rd index 6c6579d720..7633d49073 100644 --- a/man/fmt_bins.Rd +++ b/man/fmt_bins.Rd @@ -2,16 +2,7 @@ % Please edit documentation in R/format_data.R \name{fmt_bins} \alias{fmt_bins} -\title{Format column data containing bin/interval information -When using \code{cut()} (or other functions that use it in some way) -you get bins that can look like this: \code{"(0,10]"}, \code{"(10,15]"}, \code{"(15,20]"}, -\code{"(20,40]"}. This interval notation expresses the lower and upper limits of -each range. The square or round brackets define whether each of the endpoints -are included in the range (\code{[}/\verb{]} for inclusion, \code{(}/\verb{)} for exclusion). -Should bins of this sort be present in a table, the \code{fmt_bins()} function can -be used to format that syntax to a form that presents better in a display -table. It's possible to format the values of the intervals with the \code{fmt} -argument, and, the separator can be modified with the \code{sep} argument.} +\title{Format column data containing bin/interval information} \usage{ fmt_bins( data, @@ -73,7 +64,6 @@ should contain a formatting call (e.g., An object of class \code{gt_tbl}. } \description{ -Format column data containing bin/interval information When using \code{cut()} (or other functions that use it in some way) you get bins that can look like this: \code{"(0,10]"}, \code{"(10,15]"}, \code{"(15,20]"}, \code{"(20,40]"}. This interval notation expresses the lower and upper limits of diff --git a/man/fmt_icon.Rd b/man/fmt_icon.Rd index ab44ccfd1e..f74b1547ef 100644 --- a/man/fmt_icon.Rd +++ b/man/fmt_icon.Rd @@ -313,11 +313,10 @@ Let's use a portion of the \code{\link{metro}} dataset to create a \strong{gt} t Depending on which train services are offered at the subset of stations, \emph{Font Awesome} icon names will be applied to cells where the different services exist (the specific names are \code{"train-subway"}, \code{"train"}, and -\code{"train-tram"}). With \strong{tidyr}'s \code{unite()} function, those icon names -can be converged into a single column (\code{services}) with the \code{NA} values -removed. Since the names correspond to icons and they are in the correct -format (separated by commas), they can be formatted as \emph{Font Awesome} icons -with \code{fmt_icon()}. +\code{"train-tram"}). With \code{tidyr::unite()}, those icon names can be converged +into a single column (\code{services}) with the \code{NA} values removed. Since the +names correspond to icons and they are in the correct format (separated by +commas), they can be formatted as \emph{Font Awesome} icons with \code{fmt_icon()}. \if{html}{\out{
}}\preformatted{metro |> dplyr::select(name, lines, connect_rer, connect_tramway, location) |> diff --git a/man/info_icons.Rd b/man/info_icons.Rd index 3a6c769e60..88fabee9b4 100644 --- a/man/info_icons.Rd +++ b/man/info_icons.Rd @@ -17,7 +17,8 @@ of these icons as replacement text (so long as you use the \code{fa()} function from the \strong{fontawesome} package). Because there is a very large number of icons available to use in \emph{Font Awesome}, \code{info_icons()} can be used to provide us with a table that lists all the icons along with their short and -full names (either can be used with \code{\link[=fmt_icon]{fmt_icon()}}). +full names (either can be used with \code{\link[=fmt_icon]{fmt_icon()}}). It also contains +acceptable codes for \code{\link[=fmt_country]{fmt_country()}} } \section{Examples}{ diff --git a/man/location-helper.Rd b/man/location-helper.Rd index 5b014599f7..9beaf46988 100644 --- a/man/location-helper.Rd +++ b/man/location-helper.Rd @@ -74,3 +74,4 @@ Other location helper functions: \code{\link{cells_title}()} } \concept{location helper functions} +\keyword{internal} diff --git a/man/rows_add.Rd b/man/rows_add.Rd index 2753207988..817e5a9703 100644 --- a/man/rows_add.Rd +++ b/man/rows_add.Rd @@ -203,7 +203,7 @@ name of the row label. Another application is starting from nothing (really just the definition of columns) and building up a table using several invocations of \code{rows_add()}. This might be useful in interactive or programmatic applications. Here's an -example where two columns are defined with \strong{dplyr}'s \code{tibble()} function +example where two columns are defined with \code{dplyr::tibble()} (and no rows are present initially); with two calls of \code{rows_add()}, two separate rows are added. diff --git a/man/tab_spanner_delim.Rd b/man/tab_spanner_delim.Rd index 18c592d0d5..4eb185e8e9 100644 --- a/man/tab_spanner_delim.Rd +++ b/man/tab_spanner_delim.Rd @@ -235,10 +235,9 @@ two levels of spanners. We can further touch up the labels after that with }} With a summarized, filtered, and pivoted version of the \code{\link{pizzaplace}} -dataset, we can create another \strong{gt} table and then use the -\code{tab_spanner_delim()} function with the same delimiter/separator that was -used in the \strong{tidyr} \code{pivot_wider()} call. We can also process the generated -column labels with \code{\link[=cols_label_with]{cols_label_with()}}. +dataset, we can create another \strong{gt} table and then use \code{tab_spanner_delim()} +with the delimiter/separator also used in \code{tidyr::pivot_wider()}. We can also +process the generated column labels with \code{\link[=cols_label_with]{cols_label_with()}}. \if{html}{\out{
}}\preformatted{pizzaplace |> dplyr::select(name, date, type, price) |>