[R] using "by" and indicies

Jason Turner jasont at indigoindustrial.co.nz
Mon Mar 18 08:19:52 CET 2002

On Sun, Mar 17, 2002 at 09:23:41PM -0500, james.holtman at convergys.com wrote:
> You can reference the first entry in the column in the function.  See the
> example below:

Um, thanks, but I provided a similar example, saying this was what 
I didn't want to do.  I can live with "you're stuck with that way".

> Jason Turner <jasont at indigoindustrial.co.nz>@stat.math.ethz.ch on
> 03/17/2002 13:41:13
> > d1 <- data.frame(rnorm(100),rt(100,2),sin(1:100))
> > levs <- as.factor(rep(1:5,20))
> > levels(levs) <- c("low","med-lo","med","med-hi","high")
> > by(d1,levs,pairs)
> Is there an elegant way to get "low"..."high" in the main title for
> each plot, without binding "levs" to the data sent to a custom plot
> function?

I just thought that was a bit too specific for what I wanted.
I was hoping for a direct evaluation within FUN (most likely by
by back-refencncing, using get(somevar,which=-x), where somevar
and -x are the mystery to me).  Saves writing a custom wrapper to 
"plot" each time I want a new type of plot, for example.  However,
since by() winds up calling lapply(), this looks tricky.


Indigo Industrial Controls Ltd.
jasont at indigoindustrial.co.nz
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

More information about the R-help mailing list