Skip to content

boxplot with 2 treatments and 2 variables (with 2 corresponding y-axes)

3 messages · Ellis, David, Uwe Ligges, PIKAL Petr

2 days later
#
On 15.04.2011 16:20, Ellis, David wrote:
Not sure if it makes sense:
If you have two boxplots beside each other, you tend to compare them 
directly. If they are unrelated (different variables with different 
scaling as in this case), I'd be careful not to confuse the reader of 
the plot ....

Best,
Uwe Ligges
#
Hi

r-help-bounces at r-project.org napsal dne 15.04.2011 16:20:23:
I am
like
have
seperate
make a
each
that
Here is one option

x<-rnorm(10)
y<-rnorm(10)+5
trt<-sample(letters[1:2], 10, replace=T)
df<-cbind(c(x,y), rep(trt,2), rep(c("v1","v2"), each=10))
df<-as.data.frame(df)
df[,1]<-as.numeric(as.character(df[,1]))
boxplot(split(df[,1], interaction(df[,2], df[,3])))
 
however you have only one y axis. Similar result but better structured you 
can get using ggplot2 or lattice packages.

Having 2 y axes is rather confusing but you can scale your values and add 
axis annotation with
axis(....) but I doubt it is worth an effort.

Regards
Petr
http://www.R-project.org/posting-guide.html