Here is a dummy code :
library(ggplot2)
library(dplyr)
diamonds |> dplyr::filter(color %in% c("D","E", "F"), cut %in% c("Ideal","Fair"), clarity %in% c("SI2","VS2","IF")) |> ggplot(aes(x = clarity, y =carat, color=color, shape=cut)) +
stat_summary(fun.data= mean_cl_boot, geom="errorbar", width=0.05, position=position_dodge(0.7)) +
stat_summary(fun=mean, geom="point", size=2, position= position_dodge(0.7))
I would like to connect the means with a line within each clarity category ( ie connect circle to the triangle: shown in red colour on the picture as an example):
If I use geom_stat
or geom_line
: it gives an error that geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
which makes sense since both of them are within a single clarity
group. I tried to use group=interaction()
but it did not work either, I only were able to do it for points within different clarity
groups