From 4af8e3756831fede904e8bc0f6eb60183f733a7c Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 2 Feb 2024 15:00:47 +0100 Subject: [PATCH] Comment out syntax options in `geom_function()` --- R/geom-function.R | 16 ++++++++-------- man/geom_function.Rd | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/R/geom-function.R b/R/geom-function.R index 9d26ee47fa..47ce54a627 100644 --- a/R/geom-function.R +++ b/R/geom-function.R @@ -42,14 +42,14 @@ #' 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 = ~ 0.5*exp(-abs(.x))) -#' -#' # Using a custom named function -#' f <- function(x) 0.5*exp(-abs(x)) -#' -#' base + geom_function(fun = f) +#' base + geom_function(fun = function(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) #' #' # Using xlim to restrict the range of function #' ggplot(data.frame(x = rnorm(100)), aes(x)) + diff --git a/man/geom_function.Rd b/man/geom_function.Rd index be07031218..45e6b91345 100644 --- a/man/geom_function.Rd +++ b/man/geom_function.Rd @@ -146,14 +146,14 @@ 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 = ~ 0.5*exp(-abs(.x))) - -# Using a custom named function -f <- function(x) 0.5*exp(-abs(x)) - -base + geom_function(fun = f) +base + geom_function(fun = function(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) # Using xlim to restrict the range of function ggplot(data.frame(x = rnorm(100)), aes(x)) +