Skip to content
Prev 166084 / 398502 Next

Error : unused arguments in pairs()

You didn't do what Prof. Ripley suggested - adding a ... argument.
Here's a crude version of what you want; I'm sure there's a more elegant
solution for passing the needed data to the panel function.

panel.cor <- function(x, y, digits=2, prefix="", splitvar, col.cor, ...)

{
   usr <- par("usr"); on.exit(par(usr))
   par(usr = c(0, 1, 0, 1))
   r <- abs(cor(x, y))
   if(!missing(splitvar)) {
      r <- c(r, abs(sapply(lapply(split(cbind.data.frame(x, y),
splitvar), cor), function(x)x[1,2])))
   }
   txt <- format(c(r, 0.123456789), digits=digits)[1:4]
   txt <- paste(prefix, txt, sep="")
   if(missing(col.cor)) col.cor <- c("black", "red", "green3", "blue")
   for(i in 1:length(txt)) {
      text(0.5, (1/(length(txt)+1))*i, txt[i], col = col.cor[i])
   }
 }

 pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
     pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)],
lower.panel=panel.cor, splitvar=iris$Species)
On Mon, Jan 5, 2009 at 5:32 PM, herwig <bachmannherwig at hotmail.com> wrote: