Skip to content

"stage()" does not work properly when prefixed with "ggplot2::" #6104

Closed
@HMU-WH

Description

@HMU-WH

When I use a function from ggplot2 in my own R package, I need to prefix it with "ggplot2::". I found that, in this case, "stage()" does not work properly!

Here is the code to reproduce the bug:
This is the original example in ggplot2. I just changed "stage" to "ggplot2::stage".

ggplot(mpg, aes(class, displ)) +
  geom_violin() +
  stat_summary(
    aes(
      y = ggplot2::stage(displ, after_stat = 8),
      label = after_stat(paste(mean, "±", sd))
    ),
    geom = "text",
    fun.data = ~ round(data.frame(mean = mean(.x), sd = sd(.x)), 2)
  )

Throws the following error:

Error in `stat_summary()`:
! Problem while mapping stat to aesthetics.Error occurred in the 2nd layer.
Caused by error:
! object 'displ' not found

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions