Hi, I have a data set with two continous variables that I want to plot MEANS (I am not intrerested in median values) on a double-y graph. I also have 2 factors. I want the factor combinations plotted in different panes.
Dummy dataset: mydata <- data.frame(factor1 = factor(rep(LETTERS[1:3], each = 40)), factor2 = factor(rep(c(1:4), each = 10)), y1 = rnorm(120, mean = rep(c(0, 3, 5), each = 40), sd = rep(c(1, 2, 3), each = 20)), y2 = rnorm(120, mean = rep(c(6, 7, 8), each = 40), sd = rep(c(1, 2, 3), each = 20))) I have tried plotrix(), but I everything is overlaid. Also, I am pretty sure that the means are wrong as I have assumed that the below calculates the mean of each factor level separately and not the mean per level factor 1 AND factor 2. Is there a way of doing this in ggplot2? I have also tried plotmeans() in the sciplot package, but was unsuccessful. Sincerely Anna Zakrisson library(plotrix) ?brkdn.plot par(family="serif",font=1) brkdn.plot("y1", "factor1","factor2", data=mydata, mct="mean",md="sd", main="", cex=0.8, stagger=NA, xlab="factor1", ylab = "y1", dispbar=TRUE, type="b",pch=c(0),lty=1,col=par("fg")) par(new=TRUE) brkdn.plot("y2","factor1", "factor2",data=mydata, mct="mean",md="sd", main="", cex=0.8, stagger=NA, xlab="", ylab = "", dispbar=TRUE, type="b",pch=1,lty=2,col=par("fg")) axis(4) mtext("y2",side=4,line=3) legend("topleft",col=c("black","black"),bty="n", lty=c(1:2),legend=c("y1","y2")) Anna Zakrisson Braeunlich PhD Student Department of Ecology Environment and Plant Sciences Stockholm University Svante Arrheniusv. 21A SE-106 91 Stockholm Lives in Berlin. For paper mail: Katzbachstr. 21 D-10965, Berlin - Kreuzberg Germany/Deutschland E-mail: anna.zakris...@su.se Tel work: +49-(0)3091541281 Mobile: +49-(0)15777374888 LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b ><((((º>`â¢. . ⢠`â¢. .⢠`â¢. . ><((((º>`â¢. . ⢠`â¢. .⢠`â¢. .><((((º> [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.