Is there a difference between `geom_a (stat =" b ", ...)` and `stat_b (geom =" a ", ...)`?

I saw both use cases, but I do not know the difference between 2 in practice.

And why

stat_vline(xintercept="mean", geom="vline") # this works 

But

 geom_vline(xintercept="mean", stat="vline") # this doesn't work 

Does this mean that after passing mean to the next layer, which in this case is equal to vline , the function becomes a symbol? Is this common behavior?

+6
source share
1 answer

You may have found a bug. If you specify an aesthetics mapping (again), it will work:

 p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() p + geom_vline(aes(x=wt, y=mpg), xintercept="mean", stat="vline") 

The typical ggplot2 documentation is somewhat sparse, making it difficult to evaluate whether this is intentional.

+8
source

Source: https://habr.com/ru/post/953776/


All Articles