Open yutannihilation opened 5 years ago
I agree this makes some sense, and will be a good fallback for situations where the provides stats does t do exactly what the user need. One thing that complicated it all is in terms of documenting what kind of columns should get returned. This is quite dependent on the geom it gets coupled with and will require some knowledge on how ggplot2 works
Every time I encounter a question like #3497, I wonder why ggplot2 doesn't have a
Stat
that simply applies a function by group. Though, in terms of the computational efficiency, it's generally better to have a summarised version of the data before entering ggplot2, it would be handy if we can summarise in ggplot2 especially when we generate plots one after another with different groupings.I believe
StatSummary
could have been implemented to be able to summarise data with other groupings thanc("group", "x")
because the code following seems very general one:https://github.com/tidyverse/ggplot2/blob/b8420241309c8eea00d7086002c01cdf38a50eac/R/stat-summary.r#L163-L169
But, as the current
make_summary_fun()
expects a function that takes a vector, not a data.frame, it would be difficult to expandStatSummary
to accept a function that summarises bothx
andy
. So, to satisfy the need, I feel it might be nice to have some simple geom like below.I don't see reasons why we shouldn't implement such a Stat. Am I missing something...?
Created on 2019-08-24 by the reprex package (v0.3.0)