From 05559cf54733893fc26e449feb3d1f4517ce57b8 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:16:30 +0200 Subject: [PATCH 01/11] update last upkeep field --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1ce0af70d4..005dea5988 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -76,7 +76,7 @@ VignetteBuilder: knitr Config/Needs/website: ggtext, tidyr, forcats, tidyverse/tidytemplate Config/testthat/edition: 3 -Config/usethis/last-upkeep: 2024-10-24 +Config/usethis/last-upkeep: 2025-04-23 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) From 4b129b436800956b59757a50d343cf63dc7b00f3 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:16:39 +0200 Subject: [PATCH 02/11] bump required R version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 005dea5988..9345b93c32 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,7 @@ License: MIT + file LICENSE URL: https://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2 BugReports: https://github.com/tidyverse/ggplot2/issues Depends: - R (>= 4.0) + R (>= 4.1) Imports: cli, grDevices, From cc7110f50d2153cbb2cbd00115a90b9ce5fba1e8 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:35:07 +0200 Subject: [PATCH 03/11] replace `%>%` with `|>` --- R/geom-map.R | 2 +- R/utilities-tidy-eval.R | 14 +++++++------- man/geom_map.Rd | 2 +- man/tidyeval.Rd | 14 +++++++------- tests/testthat/test-facet-.R | 2 +- tests/testthat/test-stat-bin.R | 2 +- vignettes/articles/faq-annotation.Rmd | 16 ++++++++-------- vignettes/articles/faq-bars.Rmd | 12 ++++++------ vignettes/articles/faq-faceting.Rmd | 4 ++-- vignettes/articles/faq-reordering.Rmd | 12 ++++++------ 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/R/geom-map.R b/R/geom-map.R index 0632ba36ee..bb079610e6 100644 --- a/R/geom-map.R +++ b/R/geom-map.R @@ -55,7 +55,7 @@ NULL #' #' crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests) #' -#' # Equivalent to crimes %>% tidyr::pivot_longer(Murder:Rape) +#' # Equivalent to crimes |> tidyr::pivot_longer(Murder:Rape) #' vars <- lapply(names(crimes)[-1], function(j) { #' data.frame(state = crimes$state, variable = j, value = crimes[[j]]) #' }) diff --git a/R/utilities-tidy-eval.R b/R/utilities-tidy-eval.R index eac1085256..41895f4fcb 100644 --- a/R/utilities-tidy-eval.R +++ b/R/utilities-tidy-eval.R @@ -23,8 +23,8 @@ #' #' ``` #' my_function <- function(data, var, ...) { -#' data %>% -#' group_by(...) %>% +#' data |> +#' group_by(...) |> #' summarise(mean = mean({{ var }})) #' } #' ``` @@ -43,8 +43,8 @@ #' dots <- enquos(...) #' #' # Inject -#' data %>% -#' group_by(!!!dots) %>% +#' data |> +#' group_by(!!!dots) |> #' summarise(mean = mean(!!var)) #' } #' ``` @@ -60,7 +60,7 @@ #' #' ``` #' my_var <- "disp" -#' mtcars %>% summarise(mean = mean(.data[[my_var]])) +#' mtcars |> summarise(mean = mean(.data[[my_var]])) #' ``` #' #' * Another tidy eval operator is `:=`. It makes it possible to use @@ -72,7 +72,7 @@ #' my_function <- function(data, var, suffix = "foo") { #' # Use `{{` to tunnel function arguments and the usual glue #' # operator `{` to interpolate plain strings. -#' data %>% +#' data |> #' summarise("{{ var }}_mean_{suffix}" := mean({{ var }})) #' } #' ``` @@ -87,7 +87,7 @@ #' my_function <- function(data, var, suffix = "foo") { #' var <- enquo(var) #' prefix <- as_label(var) -#' data %>% +#' data |> #' summarise("{prefix}_mean_{suffix}" := mean(!!var)) #' } #' ``` diff --git a/man/geom_map.Rd b/man/geom_map.Rd index 561a297161..35677e8e0f 100644 --- a/man/geom_map.Rd +++ b/man/geom_map.Rd @@ -159,7 +159,7 @@ if (require(maps)) { crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests) - # Equivalent to crimes \%>\% tidyr::pivot_longer(Murder:Rape) + # Equivalent to crimes |> tidyr::pivot_longer(Murder:Rape) vars <- lapply(names(crimes)[-1], function(j) { data.frame(state = crimes$state, variable = j, value = crimes[[j]]) }) diff --git a/man/tidyeval.Rd b/man/tidyeval.Rd index 41fed21ef8..36266b4153 100644 --- a/man/tidyeval.Rd +++ b/man/tidyeval.Rd @@ -35,8 +35,8 @@ passed from function arguments inside other tidy eval functions. arguments contained in dots, use \code{...} in the normal way. \if{html}{\out{
}}\preformatted{my_function <- function(data, var, ...) \{ - data \%>\% - group_by(...) \%>\% + data |> + group_by(...) |> summarise(mean = mean(\{\{ var \}\})) \} }\if{html}{\out{
}} @@ -53,8 +53,8 @@ into an evaluation context with \verb{!!} (for a single expression) and dots <- enquos(...) # Inject - data \%>\% - group_by(!!!dots) \%>\% + data |> + group_by(!!!dots) |> summarise(mean = mean(!!var)) \} }\if{html}{\out{}} @@ -68,7 +68,7 @@ slice of data. If you have a variable name in a string, use the \code{.data} pronoun to subset that variable with \code{[[}. \if{html}{\out{
}}\preformatted{my_var <- "disp" -mtcars \%>\% summarise(mean = mean(.data[[my_var]])) +mtcars |> summarise(mean = mean(.data[[my_var]])) }\if{html}{\out{
}} \item Another tidy eval operator is \verb{:=}. It makes it possible to use glue and curly-curly syntax on the LHS of \code{=}. For technical @@ -78,7 +78,7 @@ the left of \code{=}, so we use \verb{:=} as a workaround. \if{html}{\out{
}}\preformatted{my_function <- function(data, var, suffix = "foo") \{ # Use `\{\{` to tunnel function arguments and the usual glue # operator `\{` to interpolate plain strings. - data \%>\% + data |> summarise("\{\{ var \}\}_mean_\{suffix\}" := mean(\{\{ var \}\})) \} }\if{html}{\out{
}} @@ -91,7 +91,7 @@ can be reproduced manually with: \if{html}{\out{
}}\preformatted{my_function <- function(data, var, suffix = "foo") \{ var <- enquo(var) prefix <- as_label(var) - data \%>\% + data |> summarise("\{prefix\}_mean_\{suffix\}" := mean(!!var)) \} }\if{html}{\out{
}} diff --git a/tests/testthat/test-facet-.R b/tests/testthat/test-facet-.R index a24a5e4ca5..71f78c1cf2 100644 --- a/tests/testthat/test-facet-.R +++ b/tests/testthat/test-facet-.R @@ -230,7 +230,7 @@ test_that("facet variables", { test_that("facet gives clear error if ", { df <- data_frame(x = 1) expect_snapshot_error(print(ggplot(df, aes(x)) + facet_grid(x ~ x))) - expect_snapshot_error(print(ggplot(df, aes(x)) %>% facet_grid(. ~ x))) + expect_snapshot_error(print(ggplot(df, aes(x)) |> facet_grid(. ~ x))) expect_snapshot_error(print(ggplot(df, aes(x)) + facet_grid(list(1, 2, 3)))) expect_snapshot_error(print(ggplot(df, aes(x)) + facet_grid(vars(x), "free"))) }) diff --git a/tests/testthat/test-stat-bin.R b/tests/testthat/test-stat-bin.R index de1c941b1e..3568faa819 100644 --- a/tests/testthat/test-stat-bin.R +++ b/tests/testthat/test-stat-bin.R @@ -73,7 +73,7 @@ test_that("fuzzy breaks are used when cutting", { p <- ggplot(df, aes(x)) + geom_histogram(binwidth = 0.1, boundary = 0.1, closed = "left") - bins <- get_layer_data(p) %>% subset(count > 0) %>% .[1:5] + bins <- get_layer_data(p) |> subset(count > 0) |> head(5) expect_equal(bins$count, c(1, 1, 1, 1)) }) diff --git a/vignettes/articles/faq-annotation.Rmd b/vignettes/articles/faq-annotation.Rmd index ff382d40b3..6057b63fbd 100644 --- a/vignettes/articles/faq-annotation.Rmd +++ b/vignettes/articles/faq-annotation.Rmd @@ -142,8 +142,8 @@ Note that we expanded the y axis limit to get the numbers to fit on the plot. ```{r} #| fig.alt: "A bar chart showing the number of cars for each of three types #| of drive train. The count values are displayed on top of the bars as text." -mpg %>% - dplyr::count(drv) %>% +mpg |> + dplyr::count(drv) |> ggplot(aes(x = drv, y = n)) + geom_col() + geom_text(aes(label = n), vjust = -0.5) + @@ -184,7 +184,7 @@ ggplot(mpg, aes(x = class, fill = drv)) + You can first calculate the counts for each segment with `dplyr::count()`, which will place these values in a column called `n`. ```{r} -mpg %>% +mpg |> count(class, drv) ``` @@ -195,8 +195,8 @@ You can then pass this result directly to `ggplot()`, draw the segments with app #| types of cars. The fill colour of the bars indicate the type of drive #| train. In the middle of each filled part, the count value is displayed as #| text." -mpg %>% - count(class, drv) %>% +mpg |> + count(class, drv) |> ggplot(aes(x = class, fill = drv, y = n)) + geom_col() + geom_text(aes(label = n), size = 3, position = position_stack(vjust = 0.5)) @@ -226,9 +226,9 @@ One option is to calculate the proportions with `dplyr::count()` and then use `g ```{r} #| fig.alt: "A bar chart showing the proportion of cars for each of three types #| of drive train." -mpg %>% - dplyr::count(drv) %>% - mutate(prop = n / sum(n)) %>% +mpg |> + dplyr::count(drv) |> + mutate(prop = n / sum(n)) |> ggplot(aes(x = drv, y = prop)) + geom_col() ``` diff --git a/vignettes/articles/faq-bars.Rmd b/vignettes/articles/faq-bars.Rmd index daae53ef58..1ba10653c9 100644 --- a/vignettes/articles/faq-bars.Rmd +++ b/vignettes/articles/faq-bars.Rmd @@ -258,7 +258,7 @@ poll <- tribble( You can first pivot the data longer to obtain a data frame with one row per party/opinion combination and a new column, `n`, for the number of responses that fall into that category. ```{r} -poll_longer <- poll %>% +poll_longer <- poll |> pivot_longer( cols = -party, names_to = "opinion", @@ -318,12 +318,12 @@ Then, pass the resulting longer data frame to `ggplot()` group responses for eac #| fig.alt: "A grouped bar chart showing the number of responses to three #| questions. Within each question, two bars denote an 'Agree' or 'Disagree' #| response." -survey %>% +survey |> tidyr::pivot_longer( cols = -respondent, names_to = "question", values_to = "response" - ) %>% + ) |> ggplot(aes(x = question, fill = response)) + geom_bar(position = "dodge") ``` @@ -344,9 +344,9 @@ Then, you can pass the resulting data frame to `ggplot()` and plot bars using `g ```{r} #| fig.alt: "A bar chart showing the average highway miles per gallon for #| three types of drive train." -mpg %>% - group_by(drv) %>% - summarise(mean_hwy = mean(hwy)) %>% +mpg |> + group_by(drv) |> + summarise(mean_hwy = mean(hwy)) |> ggplot(aes(x = drv, y = mean_hwy)) + geom_col() ``` diff --git a/vignettes/articles/faq-faceting.Rmd b/vignettes/articles/faq-faceting.Rmd index d5a6926d83..25ad44e174 100644 --- a/vignettes/articles/faq-faceting.Rmd +++ b/vignettes/articles/faq-faceting.Rmd @@ -121,8 +121,8 @@ First, calculate these means and save them in a new data frame. ```{r} library(dplyr) -mpg_summary <- mpg %>% - group_by(drv) %>% +mpg_summary <- mpg |> + group_by(drv) |> summarise(hwy_mean = mean(hwy)) mpg_summary diff --git a/vignettes/articles/faq-reordering.Rmd b/vignettes/articles/faq-reordering.Rmd index 964dd6ba08..1cdfa2571c 100644 --- a/vignettes/articles/faq-reordering.Rmd +++ b/vignettes/articles/faq-reordering.Rmd @@ -234,9 +234,9 @@ Now the blue circle is over the yellow triangle since 0.01 comes after 0 and sim #| four x-positions, of which two are very distinct. Every point has a distinct #| shape and colour. A blue circle is plotted on top of a yellow triangle. A #| red square is plotted on top of a black asterisk." -df_arranged <- df %>% dplyr::arrange(x) +df_arranged <- df |> dplyr::arrange(x) -df_arranged %>% +df_arranged |> ggplot(aes(x = x, y = y, fill = fill, shape = shape)) + geom_point(size = 8) + scale_shape_identity() + @@ -257,14 +257,14 @@ If you wanted to make sure that the observation identified with an asterisk is a #| asterisk is plotted on top of a red square." ggplot(mapping = aes(x = x, y = y, fill = fill, shape = shape)) + - geom_point(data = df %>% filter(shape != "asterisk"), size = 8) + - geom_point(data = df %>% filter(shape == "asterisk"), size = 8) + + geom_point(data = df |> filter(shape != "asterisk"), size = 8) + + geom_point(data = df |> filter(shape == "asterisk"), size = 8) + scale_shape_identity() + scale_fill_identity() ggplot(mapping = aes(x = x, y = y, fill = fill, shape = shape)) + - geom_point(data = df_arranged %>% filter(shape != "asterisk"), size = 8) + - geom_point(data = df_arranged %>% filter(shape == "asterisk"), size = 8) + + geom_point(data = df_arranged |> filter(shape != "asterisk"), size = 8) + + geom_point(data = df_arranged |> filter(shape == "asterisk"), size = 8) + scale_shape_identity() + scale_fill_identity() ``` From 84d202f6683ed9adfecaa5cd04465210bcd7875d Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:51:16 +0200 Subject: [PATCH 04/11] Convert some simple anonymous functions to shorthand --- R/aes.R | 2 +- R/annotation-logticks.R | 4 ++-- R/geom-function.R | 4 +--- R/geom-histogram.R | 2 +- R/labeller.R | 2 +- R/stat-summary-2d.R | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/R/aes.R b/R/aes.R index de3376071d..2abf7efb10 100644 --- a/R/aes.R +++ b/R/aes.R @@ -88,7 +88,7 @@ NULL #' #' # Note that users of your wrapper can use their own functions in the #' # quoted expressions and all will resolve as it should! -#' cut3 <- function(x) cut_number(x, 3) +#' cut3 <- \(x) cut_number(x, 3) #' scatter_by(mtcars, cut3(disp), drat) aes <- function(x, y, ...) { xs <- arg_enquos("x") diff --git a/R/annotation-logticks.R b/R/annotation-logticks.R index 600bd6ce7c..ae1eaf4247 100644 --- a/R/annotation-logticks.R +++ b/R/annotation-logticks.R @@ -43,11 +43,11 @@ #' a <- ggplot(msleep, aes(bodywt, brainwt)) + #' geom_point(na.rm = TRUE) + #' scale_x_log10( -#' breaks = scales::trans_breaks("log10", function(x) 10^x), +#' breaks = scales::trans_breaks("log10", \(x) 10^x), #' labels = scales::trans_format("log10", scales::math_format(10^.x)) #' ) + #' scale_y_log10( -#' breaks = scales::trans_breaks("log10", function(x) 10^x), +#' breaks = scales::trans_breaks("log10", \(x) 10^x), #' labels = scales::trans_format("log10", scales::math_format(10^.x)) #' ) + #' theme_bw() diff --git a/R/geom-function.R b/R/geom-function.R index c566731996..b1287eea07 100644 --- a/R/geom-function.R +++ b/R/geom-function.R @@ -42,11 +42,9 @@ #' geom_function(aes(colour = "t, df = 1"), fun = dt, args = list(df = 1)) #' #' # Using a custom anonymous function -#' base + geom_function(fun = function(x) 0.5 * exp(-abs(x))) +#' base + geom_function(fun = \(x) 0.5 * exp(-abs(x))) #' # or using lambda syntax: #' # base + geom_function(fun = ~ 0.5 * exp(-abs(.x))) -#' # or in R4.1.0 and above: -#' # base + geom_function(fun = \(x) 0.5 * exp(-abs(x))) #' # or using a custom named function: #' # f <- function(x) 0.5 * exp(-abs(x)) #' # base + geom_function(fun = f) diff --git a/R/geom-histogram.R b/R/geom-histogram.R index 7bd832b611..8602c07005 100644 --- a/R/geom-histogram.R +++ b/R/geom-histogram.R @@ -132,7 +132,7 @@ #' # different ranges because the function will be called once per facet #' ggplot(economics_long, aes(value)) + #' facet_wrap(~variable, scales = 'free_x') + -#' geom_histogram(binwidth = function(x) 2 * IQR(x) / (length(x)^(1/3))) +#' geom_histogram(binwidth = \(x) 2 * IQR(x) / (length(x)^(1/3))) geom_histogram <- function(mapping = NULL, data = NULL, stat = "bin", position = "stack", ..., diff --git a/R/labeller.R b/R/labeller.R index 9afd572da0..2dfda9896d 100644 --- a/R/labeller.R +++ b/R/labeller.R @@ -85,7 +85,7 @@ #' p + facet_grid(. ~ cyl2, labeller = label_parsed) #' #' # Include optional argument in label function -#' p + facet_grid(. ~ cyl, labeller = function(x) label_both(x, sep = "=")) +#' p + facet_grid(. ~ cyl, labeller = \(x) label_both(x, sep = "=")) #' } #' @name labellers NULL diff --git a/R/stat-summary-2d.R b/R/stat-summary-2d.R index 41d0c5b588..c17956840d 100644 --- a/R/stat-summary-2d.R +++ b/R/stat-summary-2d.R @@ -35,7 +35,7 @@ #' d + stat_summary_2d() #' #' # Specifying function -#' d + stat_summary_2d(fun = function(x) sum(x^2)) +#' d + stat_summary_2d(fun = \(x) sum(x^2)) #' d + stat_summary_2d(fun = ~ sum(.x^2)) #' d + stat_summary_2d(fun = var) #' d + stat_summary_2d(fun = "quantile", fun.args = list(probs = 0.1)) From bbbdc8c5c39b43b442041e2c6d363c89f4de4e9f Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:51:53 +0200 Subject: [PATCH 05/11] add ROR --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9345b93c32..4f25a3e9af 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,7 @@ Authors@R: c( comment = c(ORCID = "0000-0002-9415-4582")), person("Teun", "van den Brand", role = "aut", comment = c(ORCID = "0000-0002-9335-7468")), - person("Posit, PBC", role = c("cph", "fnd")) + person("Posit, PBC", role = c("cph", "fnd"), comment = c(ROR = "03wc8by49")) ) Description: A system for 'declaratively' creating graphics, based on "The Grammar of Graphics". You provide the data, tell 'ggplot2' how to map From 19baafb5ae3b43a73f630780049581cfd9b10b2c Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:56:08 +0200 Subject: [PATCH 06/11] bump licence year --- LICENSE | 2 +- LICENSE.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index f4515a155b..b0469670b3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2024 +YEAR: 2025 COPYRIGHT HOLDER: ggplot2 core developer team diff --git a/LICENSE.md b/LICENSE.md index ce73598634..7c6a53d75e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # MIT License -Copyright (c) 2024 ggplot2 core developer team +Copyright (c) 2025 ggplot2 core developer team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 4c8d9af4b135fd1bdceb33932c1a1487fde2eb3b Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:56:31 +0200 Subject: [PATCH 07/11] tidy description --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4f25a3e9af..3b4d91db44 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,8 @@ Authors@R: c( comment = c(ORCID = "0000-0002-9415-4582")), person("Teun", "van den Brand", role = "aut", comment = c(ORCID = "0000-0002-9335-7468")), - person("Posit, PBC", role = c("cph", "fnd"), comment = c(ROR = "03wc8by49")) + person("Posit, PBC", role = c("cph", "fnd"), + comment = c(ROR = "03wc8by49")) ) Description: A system for 'declaratively' creating graphics, based on "The Grammar of Graphics". You provide the data, tell 'ggplot2' how to map From dd66f7de225d0dd7b728577adb7b777651483439 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 09:58:00 +0200 Subject: [PATCH 08/11] tidy GHA --- .github/workflows/test-coverage.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 988226098e..eb448e9c28 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -35,14 +35,16 @@ jobs: clean = FALSE, install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") ) + print(cov) covr::to_cobertura(cov) shell: Rscript {0} - - uses: codecov/codecov-action@v4 + - uses: codecov/codecov-action@v5 with: - fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} - file: ./cobertura.xml - plugin: noop + # Fail if error if not on PR, or if on PR and token is given + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} + files: ./cobertura.xml + plugins: noop disable_search: true token: ${{ secrets.CODECOV_TOKEN }} From 527613cae8b87f9945d6a763d9110e514fe8e072 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 14:03:52 +0200 Subject: [PATCH 09/11] document --- man/aes.Rd | 2 +- man/annotation_logticks.Rd | 4 ++-- man/geom_function.Rd | 4 +--- man/geom_histogram.Rd | 2 +- man/ggplot2-package.Rd | 2 +- man/labellers.Rd | 2 +- man/stat_summary_2d.Rd | 2 +- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/man/aes.Rd b/man/aes.Rd index ed77c5d39e..1359e78db8 100644 --- a/man/aes.Rd +++ b/man/aes.Rd @@ -88,7 +88,7 @@ scatter_by(mtcars, disp, drat) # Note that users of your wrapper can use their own functions in the # quoted expressions and all will resolve as it should! -cut3 <- function(x) cut_number(x, 3) +cut3 <- \(x) cut_number(x, 3) scatter_by(mtcars, cut3(disp), drat) } \seealso{ diff --git a/man/annotation_logticks.Rd b/man/annotation_logticks.Rd index 490a7d3b17..3c4d82932b 100644 --- a/man/annotation_logticks.Rd +++ b/man/annotation_logticks.Rd @@ -73,11 +73,11 @@ These tick marks probably make sense only for base 10. a <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_log10( - breaks = scales::trans_breaks("log10", function(x) 10^x), + breaks = scales::trans_breaks("log10", \(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + scale_y_log10( - breaks = scales::trans_breaks("log10", function(x) 10^x), + breaks = scales::trans_breaks("log10", \(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + theme_bw() diff --git a/man/geom_function.Rd b/man/geom_function.Rd index be0a23541d..e6ce223066 100644 --- a/man/geom_function.Rd +++ b/man/geom_function.Rd @@ -196,11 +196,9 @@ base + geom_function(aes(colour = "t, df = 1"), fun = dt, args = list(df = 1)) # Using a custom anonymous function -base + geom_function(fun = function(x) 0.5 * exp(-abs(x))) +base + geom_function(fun = \(x) 0.5 * exp(-abs(x))) # or using lambda syntax: # base + geom_function(fun = ~ 0.5 * exp(-abs(.x))) -# or in R4.1.0 and above: -# base + geom_function(fun = \(x) 0.5 * exp(-abs(x))) # or using a custom named function: # f <- function(x) 0.5 * exp(-abs(x)) # base + geom_function(fun = f) diff --git a/man/geom_histogram.Rd b/man/geom_histogram.Rd index f0532d8b25..5f8cf3f6e6 100644 --- a/man/geom_histogram.Rd +++ b/man/geom_histogram.Rd @@ -331,7 +331,7 @@ m + # different ranges because the function will be called once per facet ggplot(economics_long, aes(value)) + facet_wrap(~variable, scales = 'free_x') + - geom_histogram(binwidth = function(x) 2 * IQR(x) / (length(x)^(1/3))) + geom_histogram(binwidth = \(x) 2 * IQR(x) / (length(x)^(1/3))) } \seealso{ \code{\link[=stat_count]{stat_count()}}, which counts the number of cases at each x diff --git a/man/ggplot2-package.Rd b/man/ggplot2-package.Rd index 23ed67a2a5..4a57a87766 100644 --- a/man/ggplot2-package.Rd +++ b/man/ggplot2-package.Rd @@ -37,7 +37,7 @@ Authors: Other contributors: \itemize{ - \item Posit, PBC [copyright holder, funder] + \item Posit, PBC (03wc8by49) [copyright holder, funder] } } diff --git a/man/labellers.Rd b/man/labellers.Rd index 09f160bf40..70ac8bf712 100644 --- a/man/labellers.Rd +++ b/man/labellers.Rd @@ -110,7 +110,7 @@ p + facet_grid(. ~ cyl2) p + facet_grid(. ~ cyl2, labeller = label_parsed) # Include optional argument in label function -p + facet_grid(. ~ cyl, labeller = function(x) label_both(x, sep = "=")) +p + facet_grid(. ~ cyl, labeller = \(x) label_both(x, sep = "=")) } } \seealso{ diff --git a/man/stat_summary_2d.Rd b/man/stat_summary_2d.Rd index da62dd0a15..1945135985 100644 --- a/man/stat_summary_2d.Rd +++ b/man/stat_summary_2d.Rd @@ -196,7 +196,7 @@ d <- ggplot(diamonds, aes(carat, depth, z = price)) d + stat_summary_2d() # Specifying function -d + stat_summary_2d(fun = function(x) sum(x^2)) +d + stat_summary_2d(fun = \(x) sum(x^2)) d + stat_summary_2d(fun = ~ sum(.x^2)) d + stat_summary_2d(fun = var) d + stat_summary_2d(fun = "quantile", fun.args = list(probs = 0.1)) From b98245323b3ace85b6615d947410a4a984031a01 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 20 May 2025 08:59:45 +0200 Subject: [PATCH 10/11] exempt `cut3()` from short function form --- R/aes.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/aes.R b/R/aes.R index d38d7373a0..33eae1de83 100644 --- a/R/aes.R +++ b/R/aes.R @@ -88,7 +88,7 @@ NULL #' #' # Note that users of your wrapper can use their own functions in the #' # quoted expressions and all will resolve as it should! -#' cut3 <- \(x) cut_number(x, 3) +#' cut3 <- function(x) cut_number(x, 3) #' scatter_by(mtcars, cut3(disp), drat) aes <- function(x, y, ...) { xs <- arg_enquos("x") From 60f6870f0d3f5bb17db8b195ba4ccc9f7c4160f5 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Tue, 20 May 2025 09:03:17 +0200 Subject: [PATCH 11/11] redocument --- man/aes.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/aes.Rd b/man/aes.Rd index 1359e78db8..ed77c5d39e 100644 --- a/man/aes.Rd +++ b/man/aes.Rd @@ -88,7 +88,7 @@ scatter_by(mtcars, disp, drat) # Note that users of your wrapper can use their own functions in the # quoted expressions and all will resolve as it should! -cut3 <- \(x) cut_number(x, 3) +cut3 <- function(x) cut_number(x, 3) scatter_by(mtcars, cut3(disp), drat) } \seealso{