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

2011-06-26 Thread Saalem Adera
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,100), 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.ad...@gmail.com

__
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.


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

2011-06-26 Thread Deepayan Sarkar
On Mon, Jun 27, 2011 at 2:35 AM, Saalem Adera saalemad...@gmail.com wrote:
 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,100), 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.”))

Looks reasonable to me. As you have the data and we do not, only you
can figure out why this did not lead to success.

 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.

Lattice does not support axis breaks (at least not what I think of as
axis breaks).

 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?

As you have a one-column layout, you should be able to do this with a
vector ylab, e.g. ylab = c(lab1, lab2, ..., lab6).

-Deepayan

__
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.