I'm trying to connect ggplot2 boxplots with geom_lines for multiple factors. I'd been able to accomplish so far to connect all the boxplot with lines, see attach picture. But I wish to connect the only boxplots by their corresponding factor.
For example for my variable FL, I want to connect only those two boxplot, without connecting them with the remaining variables. Similarly for the variable RW, connecting those two sex boxplot without the remaining others.
library("MASS")
data(crabs)
melt_crabs <- melt(crabs,id.var=c("sp","sex","index"))
ggplot(melt_crabs, aes(x = variable, y = value)) + geom_line(aes(group = index), size = 0.05, alpha = 0.7) + geom_boxplot(aes(fill = sp), alpha = 0.5) + facet_grid(sex~.)
Does anyone know how to achieve this? I hope I'd explain myself the most clear way.
Many thanks and best wishes,
See Question&Answers more detail:os