stat_binmean | R Documentation |
Plot the mean of y over the mean of x within bins of x.
stat_binmean(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
na.rm = FALSE,
n = 20,
...
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
na.rm |
If |
n |
number of x-bins. Default to 20. Set to zero if you want to use distinct value of x for grouping. |
... |
Other arguments passed on to |
a data.frame with additional columns:
xtile |
bins for x |
x |
mean of x |
y |
mean of y |
library(ggplot2)
g <- ggplot(iris, aes(x = Sepal.Width , y = Sepal.Length)) + stat_binmean(n = 10)
g + stat_smooth(method = "lm", se = FALSE)
ggplot(iris, aes(x = Sepal.Width , y = Sepal.Length, color = Species)) + stat_binmean(n = 10)
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, weight = Petal.Length)) + stat_binmean(n = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.