[R] Superposing data on boxplot

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Tue May 4 17:36:11 CEST 2004


Thanks, Andy, and Peter Wolf, for very prompt replies!

On 04-May-04 Liaw, Andy wrote:
> Try:
> 
> y = rnorm(50)
> z = factor(rep(1:5, each=10))
> boxplot(y~z, horizontal=TRUE)
> stripchart(y~z, add=TRUE)

Actually the other way up works the way I want. Details:

  boxplot(Y~Z)
  stripchart(Y~Z,vertical=TRUE,add=TRUE,pch=1,col="red")

which produces exactly the effect I'd been trying to achieve
with my code.

Thanks for drawing my attention to 'stripchart'. Just the job.

Peter: your suggestion

y<-rnorm(100);z<-sample(1:7,100,T);boxplot(y~z);points(y~z)

is what I would have used had Z been numerical. Unfortunately
Z is of the form c("A","B","C",...), which is why I went through
all that footwork to extract the x-coordinates of "A", "B", etc.
from bxp().

Best wishes,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 04-May-04                                       Time: 16:36:11
------------------------------ XFMail ------------------------------




More information about the R-help mailing list