I'm working in ggplot and I have a plot with the following code:
plot <- ggplot(data, aes(x=Site, y=ratio, colour = Site)) +
geom_point(stat="summary", fun.y= "mean", size = 4) +
geom_point (size = 1, alpha = .3) +
stat_summary(fun.data= mean_se, geom = "errorbar", width = .2, linewidth = 0.3) +
theme(legend.position = "none")
I'm receiving the following error message:
Warning in geom_point(stat = "summary", fun.y = "mean", size = 4) :
Ignoring unknown parameters: `fun.y`
No summary function supplied, defaulting to `mean_se()`
I'm not sure what the issue is. Thanks for any advice.
I tried replacing mean_se with mean_se() and that didn't work.
According to the docs, fun.y
is deprecated as an argument to stat_summary
, which is where the fun.y
argument inside your first geom_point
call is passed. As Onyambu says, you need to change this to fun
. You also need to change the fun = mean_se
to fun.data = mean_se
inside your direct stat_summary
call.
You haven't included your data in the question, so we have to assume that Site
is categorical and ratio
is numeric, as in the following sample:
set.seed(123)
data <- data.frame(Site = rep(LETTERS[1:3], each = 100),
ratio = runif(300, 0.5, 1) / runif(300, 0.5, 1))
Now the code could be something like:
library(ggplot2)
ggplot(data, aes(x = Site, y = ratio, colour = Site)) +
geom_point (size = 1, alpha = 0.3, position = position_jitter(0.1)) +
stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.2,
color = "black") +
geom_point(stat = "summary", fun = mean, size = 4) +
theme_minimal(base_size = 16) +
theme(legend.position = "none")