[R] Fwd: How to access the panel rows/columns in pairs()?

Marius Hofert marius.hofert at math.ethz.ch
Sat Jan 21 18:50:22 CET 2012


okay, I found something. Not very elegant, but it does the job:

## generate data
U <- matrix(runif(4000), ncol=4)

## define panel function for colorizing the panels
cols <- c("blue", "black", "black",
          "blue", "black", "black",
          "black", "black", "green",
          "black", "black", "green")
count <- 0
mypanel <- function(x, y, ...){
    count <<- count + 1
    print(count)
    points(x, y, cex=0.5, col=cols[count]) 
}

## scatter plot matrix
pairs(U, panel=mypanel)



More information about the R-help mailing list