[R] bwplot questions: box order, axis breaks, and multiple y-axis labels

Saalem Adera saalemadera at gmail.com
Sun Jun 26 23:05:41 CEST 2011


Hi all,

I used bwplot in lattice to create a 6-panel boxplot grouped by a
conditioning variable (param) that displays concentration (conc) in
response to treatment (trtmnt).  Here is the functional part of my
code followed by my three questions:

library(lattice);
ww<-read.csv(file="c:/Rdata/lattice_boxplot_prep.csv",header=TRUE,sep=",");
attach(ww);
mylist<-list(c(0,200), c(0,60), c(0,1000000), c(0,80), c(0, 5), c(0,300))
print(ww<-bwplot(conc~trtmnt| param, data=ww, layout=c(1,6),
as.table=TRUE, between=list(y=1), strip=FALSE, scales = list(y =
list(alternating = c(1,1), tck=c(1,0), rot=0, relation = "free",
limits=mylist))));
detach(ww);

1) I want to change the order of the boxes in my boxplots along the
x-axis such that my trtmnt levels are displayed in this order: CW,
ACW, AHFCW, AVFCW, Hyb., Integ., Aer. Hyb., Aer. Integ., rather than
the default alphabetical order.  I read other posts that recommended
using the factor or reorder functions to accomplish this but I have
not been able to successfully apply this to my data.  What is the
correct way to invoke the factor or reorder functions? Here is an
example of the the code that I tried without success:

trtmnt<-factor(trtmnt, levels=c(“CW”, “ACW”, “AHFCW”, “AVFCW”, “H”,
“I”, “AH”, “AI”), labels=c(“CW”, “ACW”, “AHFCW”, “AVFCW”, “Hyb.”,
“Integ.”, “Aer. Hyb.”, “Aer. Integ.”))

2) I want to specify axis breaks in the the y-axis range for each
panel.  So far I’ve been able to specify a y-axis range for each panel
but have not been able to specify axis breaks.  How can I do that?  I
tried modifying mylist in the code above to denote breaks in the axis,
but was unsuccessful.

3) I want to label the y-axis of each panel rather than just creating
one label for the entire y-axis.  I tried to do this using ylab, but
was unsuccessful.  What is the correct way to do this?

Thanks in advance for your help,
Saalem

-- 
Saalem Adera
Master of Environmental Science
saalem.adera at gmail.com



More information about the R-help mailing list