diff --git a/R/datasets.R b/R/datasets.R index 679fc99dda..1cbd22001d 100644 --- a/R/datasets.R +++ b/R/datasets.R @@ -107,6 +107,8 @@ #' @section Dataset Introduced: #' `v0.2.0.5` (March 31, 2020) #' +#' @examples +#' dplyr::glimpse(sza) "sza" #' Deluxe automobiles from the 2014-2017 period @@ -163,6 +165,8 @@ #' @section Dataset Introduced: #' `v0.2.0.5` (March 31, 2020) #' +#' @examples +#' dplyr::glimpse(gtcars) "gtcars" #' Daily S&P 500 Index data from 1950 to 2015 @@ -194,6 +198,8 @@ #' @section Dataset Introduced: #' `v0.2.0.5` (March 31, 2020) #' +#' @examples +#' dplyr::glimpse(sp500) "sp500" #' A year of pizza sales from a pizza place @@ -324,6 +330,8 @@ #' @section Dataset Introduced: #' `v0.2.0.5` (March 31, 2020) #' +#' @examples +#' dplyr::glimpse(pizzaplace) "pizzaplace" #' A toy example tibble for testing with gt: exibble @@ -366,6 +374,8 @@ #' @section Dataset Introduced: #' `v0.2.0.5` (March 31, 2020) #' +#' @examples +#' exibble "exibble" #' Populations of all municipalities in Ontario from 1996 to 2021 @@ -432,6 +442,8 @@ #' @section Dataset Introduced: #' `v0.9.0` (Mar 31, 2023) #' +#' @examples +#' dplyr::glimpse(towny) "towny" #' A table of personal information for people all over the world @@ -482,6 +494,8 @@ #' @section Dataset Introduced: #' `v0.11.0` (July 9, 2024) #' +#' @examples +#' dplyr::glimpse(peeps) "peeps" @@ -528,6 +542,8 @@ #' @section Dataset Introduced: #' `v0.11.0` (July 9, 2024) #' +#' @examples +#' dplyr::glimpse(films) "films" #' The stations of the Paris Metro @@ -595,6 +611,8 @@ #' @section Dataset Introduced: #' `v0.9.0` (Mar 31, 2023) #' +#' @examples +#' dplyr::glimpse(metro) "metro" #' Weather conditions in Gibraltar, May 2023 @@ -633,6 +651,8 @@ #' @section Dataset Introduced: #' `v0.11.0` (July 9, 2024) #' +#' @examples +#' dplyr::glimpse(gibraltar) "gibraltar" #' The fundamental physical constants @@ -674,6 +694,8 @@ #' @section Dataset Introduced: #' `v0.10.0` (October 7, 2023) #' +#' @examples +#' dplyr::glimpse(constants) "constants" #' Lab tests for one suffering from an illness @@ -759,6 +781,8 @@ #' @section Dataset Introduced: #' `v0.10.0` (October 7, 2023) #' +#' @examples +#' dplyr::glimpse(illness) "illness" #' Reaction rates for gas-phase atmospheric reactions of organic compounds @@ -855,6 +879,8 @@ #' @section Dataset Introduced: #' `v0.11.0` (July 9, 2024) #' +#' @examples +#' dplyr::glimpse(reactions) "reactions" #' Data on photolysis rates for gas-phase organic compounds @@ -906,6 +932,8 @@ #' @section Dataset Introduced: #' `v0.11.0` (July 9, 2024) #' +#' @examples +#' dplyr::glimpse(photolysis) "photolysis" #' Nuclide data @@ -959,6 +987,8 @@ #' @section Dataset Introduced: #' `v0.11.0` (July 9, 2024) #' +#' @examples +#' dplyr::glimpse(nuclides) "nuclides" #' An ADSL-flavored clinical trial toy dataset @@ -1021,6 +1051,8 @@ #' @section Dataset Introduced: #' `v0.9.0` (Mar 31, 2023) #' +#' @examples +#' dplyr::glimpse(rx_adsl) "rx_adsl" #' An ADDV-flavored clinical trial toy dataset @@ -1086,4 +1118,6 @@ #' @section Dataset Introduced: #' `v0.9.0` (Mar 31, 2023) #' +#' @examples +#' dplyr::glimpse(rx_addv) "rx_addv" diff --git a/R/tab_options.R b/R/tab_options.R index a97ea3bcb5..95055a58ee 100644 --- a/R/tab_options.R +++ b/R/tab_options.R @@ -105,7 +105,7 @@ #' elements: `heading.title`, `heading.subtitle`, `column_labels`, #' `row_group`, `footnotes`, and `source_notes`. Can be specified as a #' single-length character vector with units of pixels (e.g., `12px`) or as a -#' percentage (e.g., `80\%`). If provided as a single-length numeric vector, +#' percentage (e.g., `80%`). If provided as a single-length numeric vector, #' it is assumed that the value is given in units of pixels. The [px()] and #' [pct()] helper functions can also be used to pass in numeric values and #' obtain values as pixel or percentage units. diff --git a/man/constants.Rd b/man/constants.Rd index 21804e0296..a55df465a7 100644 --- a/man/constants.Rd +++ b/man/constants.Rd @@ -47,6 +47,9 @@ DATA-12 \code{v0.10.0} (October 7, 2023) } +\examples{ +dplyr::glimpse(constants) +} \seealso{ Other datasets: \code{\link{countrypops}}, diff --git a/man/exibble.Rd b/man/exibble.Rd index d3e0f4550a..affb088933 100644 --- a/man/exibble.Rd +++ b/man/exibble.Rd @@ -48,6 +48,9 @@ DATA-6 \code{v0.2.0.5} (March 31, 2020) } +\examples{ +exibble +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/films.Rd b/man/films.Rd index cca7ed4123..900da6a2d1 100644 --- a/man/films.Rd +++ b/man/films.Rd @@ -51,6 +51,9 @@ DATA-9 \code{v0.11.0} (July 9, 2024) } +\examples{ +dplyr::glimpse(films) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/gibraltar.Rd b/man/gibraltar.Rd index 3d3fb96c78..bb81cdb4ce 100644 --- a/man/gibraltar.Rd +++ b/man/gibraltar.Rd @@ -44,6 +44,9 @@ DATA-11 \code{v0.11.0} (July 9, 2024) } +\examples{ +dplyr::glimpse(gibraltar) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/grp_options.Rd b/man/grp_options.Rd index f131b996b4..7fc360c78b 100644 --- a/man/grp_options.Rd +++ b/man/grp_options.Rd @@ -257,7 +257,7 @@ The font sizes for the parent text element \code{table} and the following child elements: \code{heading.title}, \code{heading.subtitle}, \code{column_labels}, \code{row_group}, \code{footnotes}, and \code{source_notes}. Can be specified as a single-length character vector with units of pixels (e.g., \verb{12px}) or as a -percentage (e.g., \verb{80\\\%}). If provided as a single-length numeric vector, +percentage (e.g., \verb{80\%}). If provided as a single-length numeric vector, it is assumed that the value is given in units of pixels. The \code{\link[=px]{px()}} and \code{\link[=pct]{pct()}} helper functions can also be used to pass in numeric values and obtain values as pixel or percentage units.} diff --git a/man/gtcars.Rd b/man/gtcars.Rd index 41b0b429ad..45a995de93 100644 --- a/man/gtcars.Rd +++ b/man/gtcars.Rd @@ -61,6 +61,9 @@ DATA-3 \code{v0.2.0.5} (March 31, 2020) } +\examples{ +dplyr::glimpse(gtcars) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/illness.Rd b/man/illness.Rd index 18f7e209f6..cf6f62e34c 100644 --- a/man/illness.Rd +++ b/man/illness.Rd @@ -90,6 +90,9 @@ DATA-13 \code{v0.10.0} (October 7, 2023) } +\examples{ +dplyr::glimpse(illness) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/metro.Rd b/man/metro.Rd index 0b31c6ce9f..0d9e8555c2 100644 --- a/man/metro.Rd +++ b/man/metro.Rd @@ -73,6 +73,9 @@ DATA-10 \code{v0.9.0} (Mar 31, 2023) } +\examples{ +dplyr::glimpse(metro) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/nuclides.Rd b/man/nuclides.Rd index ac30f1e189..a40cf5b62e 100644 --- a/man/nuclides.Rd +++ b/man/nuclides.Rd @@ -59,6 +59,9 @@ DATA-16 \code{v0.11.0} (July 9, 2024) } +\examples{ +dplyr::glimpse(nuclides) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/peeps.Rd b/man/peeps.Rd index f6d97ee2db..167b4e6478 100644 --- a/man/peeps.Rd +++ b/man/peeps.Rd @@ -56,6 +56,9 @@ DATA-8 \code{v0.11.0} (July 9, 2024) } +\examples{ +dplyr::glimpse(peeps) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/photolysis.Rd b/man/photolysis.Rd index 0b829bc1e7..2d0b949410 100644 --- a/man/photolysis.Rd +++ b/man/photolysis.Rd @@ -57,6 +57,9 @@ DATA-15 \code{v0.11.0} (July 9, 2024) } +\examples{ +dplyr::glimpse(photolysis) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/pizzaplace.Rd b/man/pizzaplace.Rd index 425f43fe1b..3fedce7d7f 100644 --- a/man/pizzaplace.Rd +++ b/man/pizzaplace.Rd @@ -135,6 +135,9 @@ DATA-5 \code{v0.2.0.5} (March 31, 2020) } +\examples{ +dplyr::glimpse(pizzaplace) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/reactions.Rd b/man/reactions.Rd index 1bd838741c..b8e2b76923 100644 --- a/man/reactions.Rd +++ b/man/reactions.Rd @@ -102,6 +102,9 @@ DATA-14 \code{v0.11.0} (July 9, 2024) } +\examples{ +dplyr::glimpse(reactions) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/rx_addv.Rd b/man/rx_addv.Rd index 22df88e8f5..7626d4b986 100644 --- a/man/rx_addv.Rd +++ b/man/rx_addv.Rd @@ -71,6 +71,9 @@ DATA-18 \code{v0.9.0} (Mar 31, 2023) } +\examples{ +dplyr::glimpse(rx_addv) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/rx_adsl.Rd b/man/rx_adsl.Rd index 4e87536248..42aca7786a 100644 --- a/man/rx_adsl.Rd +++ b/man/rx_adsl.Rd @@ -68,6 +68,9 @@ DATA-17 \code{v0.9.0} (Mar 31, 2023) } +\examples{ +dplyr::glimpse(rx_adsl) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/sp500.Rd b/man/sp500.Rd index 9108bbe783..d002c30c95 100644 --- a/man/sp500.Rd +++ b/man/sp500.Rd @@ -37,6 +37,9 @@ DATA-4 \code{v0.2.0.5} (March 31, 2020) } +\examples{ +dplyr::glimpse(sp500) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/sza.Rd b/man/sza.Rd index 20764e3379..91b79a22e8 100644 --- a/man/sza.Rd +++ b/man/sza.Rd @@ -58,6 +58,9 @@ DATA-2 \code{v0.2.0.5} (March 31, 2020) } +\examples{ +dplyr::glimpse(sza) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/man/tab_options.Rd b/man/tab_options.Rd index bb7f2337c8..eedce1f8f6 100644 --- a/man/tab_options.Rd +++ b/man/tab_options.Rd @@ -261,7 +261,7 @@ The font sizes for the parent text element \code{table} and the following child elements: \code{heading.title}, \code{heading.subtitle}, \code{column_labels}, \code{row_group}, \code{footnotes}, and \code{source_notes}. Can be specified as a single-length character vector with units of pixels (e.g., \verb{12px}) or as a -percentage (e.g., \verb{80\\\%}). If provided as a single-length numeric vector, +percentage (e.g., \verb{80\%}). If provided as a single-length numeric vector, it is assumed that the value is given in units of pixels. The \code{\link[=px]{px()}} and \code{\link[=pct]{pct()}} helper functions can also be used to pass in numeric values and obtain values as pixel or percentage units.} diff --git a/man/towny.Rd b/man/towny.Rd index 8d126483dc..3ea361ac01 100644 --- a/man/towny.Rd +++ b/man/towny.Rd @@ -72,6 +72,9 @@ DATA-7 \code{v0.9.0} (Mar 31, 2023) } +\examples{ +dplyr::glimpse(towny) +} \seealso{ Other datasets: \code{\link{constants}}, diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index d90301eabc..b20dd7e4d8 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -393,6 +393,7 @@ articles: - title: Get started navbar: ~ contents: + - gt - creating-summary-lines - title: Case studies navbar: Case studies @@ -401,6 +402,7 @@ articles: - case-study-clinical-tables - title: Datasets + navbar: Datasets contents: - gt-datasets - title: Visual tests diff --git a/pkgdown/assets/gt-latex.pdf b/pkgdown/assets/gt-latex.pdf index ee24ce62e4..042fda515b 100644 Binary files a/pkgdown/assets/gt-latex.pdf and b/pkgdown/assets/gt-latex.pdf differ diff --git a/pkgdown/assets/gt-latex.tex b/pkgdown/assets/gt-latex.tex index 31a97b8774..e274ee8b0d 100644 --- a/pkgdown/assets/gt-latex.tex +++ b/pkgdown/assets/gt-latex.tex @@ -44,14 +44,28 @@ \setlength{\emergencystretch}{3em} % prevent overfull lines \setcounter{secnumdepth}{-\maxdimen} % remove section numbering % Make \paragraph and \subparagraph free-standing +\makeatletter \ifx\paragraph\undefined\else \let\oldparagraph\paragraph - \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} + \renewcommand{\paragraph}{ + \@ifstar + \xxxParagraphStar + \xxxParagraphNoStar + } + \newcommand{\xxxParagraphStar}[1]{\oldparagraph*{#1}\mbox{}} + \newcommand{\xxxParagraphNoStar}[1]{\oldparagraph{#1}\mbox{}} \fi \ifx\subparagraph\undefined\else \let\oldsubparagraph\subparagraph - \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} + \renewcommand{\subparagraph}{ + \@ifstar + \xxxSubParagraphStar + \xxxSubParagraphNoStar + } + \newcommand{\xxxSubParagraphStar}[1]{\oldsubparagraph*{#1}\mbox{}} + \newcommand{\xxxSubParagraphNoStar}[1]{\oldsubparagraph{#1}\mbox{}} \fi +\makeatother \usepackage{color} \usepackage{fancyvrb} @@ -71,7 +85,7 @@ \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}} \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}} \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}} -\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}} +\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{\textbf{#1}}} \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}} \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}} \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}} @@ -81,7 +95,7 @@ \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}} \newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}} \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}} -\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}} +\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{\textbf{#1}}} \newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}} \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}} \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}} @@ -168,6 +182,7 @@ \@ifpackageloaded{caption}{}{\usepackage{caption}} \@ifpackageloaded{subcaption}{}{\usepackage{subcaption}} \makeatother + \ifLuaTeX \usepackage{selnolig} % disable illegal ligatures \fi @@ -184,17 +199,19 @@ urlcolor={Blue}, pdfcreator={LaTeX via pandoc}} + \title{LaTeX Quarto test} \author{} -\date{2024-07-18} +\date{2024-07-19} \begin{document} \maketitle \listoftables + \begin{Shaded} \begin{Highlighting}[] -\NormalTok{devtools}\SpecialCharTok{::}\FunctionTok{load\_all}\NormalTok{(}\StringTok{"."}\NormalTok{)} +\NormalTok{pkgload}\SpecialCharTok{::}\FunctionTok{load\_all}\NormalTok{(}\StringTok{"."}\NormalTok{)} \end{Highlighting} \end{Shaded} @@ -212,6 +229,16 @@ [1] '0.11.0.9000' \end{verbatim} +\begin{Shaded} +\begin{Highlighting}[] +\NormalTok{quarto}\SpecialCharTok{::}\FunctionTok{quarto\_version}\NormalTok{()} +\end{Highlighting} +\end{Shaded} + +\begin{verbatim} +[1] '1.5.54' +\end{verbatim} + \newpage{} \begin{Shaded} @@ -348,4 +375,5 @@ + \end{document} diff --git a/vignettes/gt-datasets.Rmd b/vignettes/gt-datasets.Rmd index 6625f01344..6c1690281b 100644 --- a/vignettes/gt-datasets.Rmd +++ b/vignettes/gt-datasets.Rmd @@ -235,9 +235,7 @@ The table that we'll create from `gtcars` will meet these requirements: # Create a gt table based on a preprocessed `gtcars` gtcars |> filter(ctry_origin == "Germany") |> - group_by(mfr) |> - top_n(n = 2, msrp) |> - ungroup() |> + slice_max(n = 2, msrp, by = mfr) |> select(mfr, model, drivetrain, msrp) |> gt() |> tab_header(title = "Select German Automobiles") |> diff --git a/vignettes/gt-visual.qmd b/vignettes/gt-visual.qmd index b6bbbf5f56..a855c14186 100644 --- a/vignettes/gt-visual.qmd +++ b/vignettes/gt-visual.qmd @@ -28,6 +28,8 @@ if (isTRUE(as.logical(Sys.getenv("CI", "false"))) || identical(Sys.getenv("IN_PK } # All tables are generated in vignettes/visual_tests.R # When updating this file, update also pkgdown/assets/gt-latex.qmd +# generate the same table ID +set.seed(112) ``` ```{r} diff --git a/vignettes/gt.Rmd b/vignettes/gt.Rmd index bdb5067675..de2c9db64f 100644 --- a/vignettes/gt.Rmd +++ b/vignettes/gt.Rmd @@ -122,7 +122,7 @@ gt_tbl <- gt_tbl ``` -Footnotes live inside the **Footer** part and their footnote marks are attached to cell data. Footnotes are added with `tab_footnote()`. The helper function `cells_body()` can be used with the `location` argument to specify which data cells should be the target of the footnote. `cells_body()` has the two arguments `columns` and `rows`. For each of these, we can supply (1) a vector of colnames or rownames, (2) a vector of column/row indices, (3) bare column names wrapped in `c()` or row labels within `c()`, or (4) a select helper function (`starts_with()`, `ends_with()`, `contains()`, `matches()`, `one_of()`, and `everything()`). For `rows` specifically, we can use a conditional statement with column names as variables (e.g., `size > 15000`). +Footnotes live inside the **Footer** part and their footnote marks are attached to cell data. Footnotes are added with `tab_footnote()`. The helper function `cells_body()` can be used with the `location` argument to specify which data cells should be the target of the footnote. `cells_body()` has the two arguments `columns` and `rows`. For each of these, we can supply (1) a vector of colnames or rownames, (2) a vector of column/row indices, (3) bare column names wrapped in `c()` or row labels within `c()`, or (4) a select helper function (`starts_with()`, `ends_with()`, `contains()`, `matches()`, `all_of()`, and `everything()`). For `rows` specifically, we can use a conditional statement with column names as variables (e.g., `size > 15000`). Here is a simple example on how a footnotes can be added to a table cell. Let's add a footnote that references the `North America` and `South America` cells in the `name` column: