Skip to content
Prev 172586 / 398525 Next

Grouped Boxplot

Q1:
See if this seems any better. I took the liberty of reconstruction  
your initial example in a longer dataframe:

dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A",  
"B", "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))

#arguments to data.frame are recycled so one does not need to make the  
gl call with a
# length of 500, in fact , that only confuses things (or at least it  
does for me).

table(dta$G2,dta$g)

#       A   B   C   D
#  XX 125 125 125 125
#  YY 125 125 125 125

  boxplot( val ~ G2 + g, data=dta)

Q2:

?boxplot  #especially parameter at=

boxplot( val ~ g + G2, data=dta, at = 0.8*c(1,2,3,4,6,7,8,9),  
boxwex=0.4)