# [R] by & tapply

Steve Arthur sarthur at protogene.com
Wed Aug 30 03:20:58 CEST 2000

```Rers,

I have been using the function 'by' in such a manner:

by(LogMetric, list(Loci.Number=Loci.Number, Code.Flag=Code.Flag), plot)

with

par(mfrow=c(5,3))

to produce a single R Graphics: Device with 14 different plots on it as
described above in my 'by' statement.  Thank you for helping me thus far.

A similar command using 'tapply' can be written as well.

My problems being:

1) Although several LogMetric values may be plotted against several of
the same factors (x-value), they are not listed under the same x-value,
but as separate points (which does not make sense for an x-y plot).  When
I just use the plot(x,f) I get boxplots which I don't want, I want to see
the individual y-points above a particular x-value.

2) Using 'tapply' or 'by', can non-numeric x-labels be generate for the
plots, of which the factors are R factors.  I don't understand why the
numeric values are appearing in the first place.

3) Is there another, simpler, way to subset data and make intelligible
plots with R?  This industrial strength stuff takes two seconds in SAS (I
am not implying anything by that statement).  I would think this would be
a very common statistical task to complete.

Thanks,

steve

PS Addition to hopefully receiving good "by" and "tapply" examples from
you,

1) Can the 'for' statement 'for (var in seq) expr' use factors as
agruements?  The example in manual says 'for(i in 1:5)'.  I would want to
do something like 'for(i in Loci.Number)' w/o being able to specify a
general range in advance I am lost.  Am I lost?  Unfortunately, CRAN
rejects my two searches for 'by' and 'for'?

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```