I'm trying to create boxplots with this dataset faceting by factor mix (3 boxplots combined):
daf <- read.table("http://pastebin.com/raw.php?i=xxYjmdgD", header=T, sep="\t")
This is what the sample looks like:
ia mix Rs
1 Fluazinam 1 0.62
2 Fluazinam 1 0.76
3 Fluazinam 1 0.76
4 Fluazinam 1 0.52
5 Fluazinam 1 0.56
6 Fluazinam 1 0.20
7 Fluazinam 1 0.98
235 Carbendazim+Cresoxim-Metílico+Tebuconazole 3 0.65
236 Carbendazim+Cresoxim-Metílico+Tebuconazole 3 0.28
237 Carbendazim+Cresoxim-Metílico+Tebuconazole 3 0.41
These are my failed attempts!
library(ggplot2)
qplot( Rs, ia, data=daf) +
facet_grid(mix ~ ., scales = "free", space = "free", labeller = label_both)
» When I add the qplot( Rs, ia, data=daf, geom="boxplot")
It simply appear a line, not the box.
ggplot(data=daf, aes(x=ia, y=Rs))+
geom_boxplot(outlier.colour = "black", outlier.size = 2) +
coord_flip() + theme_bw() +
scale_y_continuous(breaks=seq(0,1,by=0.25))+
stat_summary(fun.y = mean, geom="point", shape = 4, size = 3, colour = "blue") +
facet_grid(mix ~. , scales = "free", space="free", labeller = label_both)
» It repeats every "ia" level into each "mix" level
ggplot(data=daf, aes(x=ia, y=Rs))+
geom_boxplot(outlier.colour = "black", outlier.size = 2) +
layer(data = a, mapping = aes(x = ia, y= 0, label=a$Rs.median),
geom = "text", color="NavyBlue", size=3.5) +
coord_flip() + theme_bw() +
scale_y_continuous(breaks=seq(0,1,by=0.25))+
stat_summary(fun.y = mean, geom="point", shape = 4, size = 3, colour = "blue")
Finally I'd like a combination of the three plots:
from the first plot, the facet.grid(without repeating "ia" variables), from the second one, the boxes, and from the third one the median values in the left inside margin, and if it could be possible, into each level of factor "mix", reordering the "ia" by median values...
Could someone help me with this??
Thanks in advance!