Benjamin Dickgiesser wrote: > Hi, > I am new to R and am still trying to get a grip of it. > > I have data in this format: > > Run Lab Batch Y > 1 1 1 1 608.781 > 2 2 1 2 569.670 > 3 3 1 1 689.556 > 4 4 1 2 747.541 > 5 5 1 1 618.134 > 6 6 1 2 612.182 > 7 7 1 1 680.203 > 8 8 1 2 607.766 > 9 9 1 1 726.232 > > and I want to make a boxplot of the Y values for each Batch. How would > I go about this? > I tried > boxplot(data.ceramic[ data.ceramic$Batch == "1", ]$Y ~ data.ceramic[ > data.ceramic$Batch == "2", ]$Y, horizontal=T,xlab="Y", ylab="Batch") > > but was completley wrong
Here are a few ideas, assuming your data are in the df data.frame: par(las=1, mar=c(7,10,7,7)) boxplot(Y ~ BATCH, data = df, horizontal = TRUE, names=c("Batch1", "Batch2")) boxplot(Y ~ BATCH, data = subset(df, LAB == 1), horizontal = TRUE, names=c("Batch1", "Batch2")) boxplot(Y ~ BATCH + LAB, data = df, horizontal = TRUE, names = paste("Lab", rep(1:8, each = 2), "/Batch", rep(1:2, 8), sep = "")) library(lattice) bwplot(BATCH ~ Y, data = df, horizontal=TRUE) bwplot(BATCH ~ Y | LAB, data = df, horizontal=TRUE, layout=c(1,8,1)) > Thank you for your help. > > Ben > > ______________________________________________ > R-help@stat.math.ethz.ch 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. > > -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 ______________________________________________ R-help@stat.math.ethz.ch 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.