Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat_summary and rlang lambda expressions #3568

Closed
dkahle opened this issue Oct 14, 2019 · 1 comment
Closed

stat_summary and rlang lambda expressions #3568

dkahle opened this issue Oct 14, 2019 · 1 comment

Comments

@dkahle
Copy link
Contributor

@dkahle dkahle commented Oct 14, 2019

While lambda expressions are allowed in stat_function() and a few other places, they aren't in stat_summary() type functions. Example below. Note that the args fun.y, fun.ymin, and fun.ymax are in the dev version fun, fun.min, and fun.max.

library("ggplot2")

df <- data.frame(
  x = c(1, 1, 2, 2, 3, 3),
  y = c(0, 2, 1, 3, 2, 4)
)

ggplot(df, aes(x, y)) +
  stat_summary(
    fun.y = mean,
    fun.ymin = function(y) mean(y) - 1,
    fun.ymax = function(y) mean(y) + 1
  )

ggplot(df, aes(x, y)) +
  stat_summary(
    fun.y = mean,
    fun.ymin = ~ mean(.x) - 1,
    fun.ymax = ~ mean(.x) + 1
  )
#> Warning: Computation failed in `stat_summary()`:
#> 'what' must be a function or character string

Created on 2019-10-14 by the reprex package (v0.3.0)

dkahle added a commit to dkahle/ggplot2 that referenced this issue Oct 14, 2019
@lock
Copy link

@lock lock bot commented Jun 24, 2020

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants