[R] Superposing data on boxplot

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Tue May 4 16:48:23 CEST 2004


Hi folks,

I have a vaiable Y and an associated factor Z at several (13)
levels.

  boxplot(Y~Z)

produces a nice array of boxplots, one for each level of Z,
and each duly labaelled with its level of Z.

I would like to superpose on each boxplot the actual data
points which it represents, i.e. do something conceptually
(though not in real R) expressed as

  points(Y~Z)

or

  points(Z,Y)

It can be done "with bare hands" along the lines of

  B<-boxplot(Y~Z)
  x<-bxp(B)
  X<-rep(x,ngroups)
  points(X,Y)

where ngroups is the number of data at each level of Z,
*provided* the data are pre-sorted by level of Z and in the
same order as these levels occurr in the boxplot. But of course
they're not!

OK, I could do this by hand as well, but now it's getting a bit
tedious, and I'm wondering if there's a better way.

Thanks for any suggestions,
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: 15:48:23
------------------------------ XFMail ------------------------------




More information about the R-help mailing list