[R] Index value from within function used by "by"

Jason Turner jasont at indigoindustrial.co.nz
Wed Mar 13 06:23:31 CET 2002


I'm using by() to call pairs(), and would like to put the factor
level into the title.  A toy example would be something like:


> 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.e. without something like...

my.pairs(data.frame(levs,d1)

where

my.pairs <- function(df,...) {
	main.title <- unique(df[1])
	pairs(df[-1],main=main.title)
}

which works, but bothers me.  
	
Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
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