panel.cor <- function(x, y, prefix="", method = "kendall"){ r <- cor(x, y, method = method) txt <- sprintf("%.2f", r) txt <- paste(prefix, txt, sep="") par(usr = c(0, 1, 0, 1)) text(0.5, 0.5, txt, cex = 1 + abs(r) * 4, col = "#0000ff") } panel.xy <- function(x, y) points(x, y, col = "#ff4000") ds <- d[d$mountain == "AK",] d.med <- data.frame(ss.med = tapply(ds$ss, ds$ye, median)) d.med <- cbind(d.med, unique(ds[,5:9])) pairs(d.med, lower.panel = panel.cor, upper.panel = panel.xy)