I have created scatterplot matrixes for my data but cannot for the life of me figure out how to obtain and then insert the correlations in the matrix. I had read posts online but I am generating errors. My pairs formula is

pairs(~glass_sponge+Depth+S+M+Sm+P,data=Gs)

I looked at the R help file and just tried to apply what they wrote, and tried...

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

{

usr <- par("usr"); on.exit(par(usr))

par(usr = c(0, 1, 0, 1))

r <- abs(cor(x, y))

txt <- format(c(r, 0.123456789), digits=digits)[1]

txt <- paste(prefix, txt, sep="")

if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)

text(0.5, 0.5, txt, cex = cex.cor * r)

}

pairs(Gs, upper.panel=panel.cor)

this doesnt work...which isnt surprising because I do not know what all the number mean in the example...what do I need to modify to make this error not occur? Or better yet, just make my own correlations not using this R example?

I have attached the plot. Your help is appreciated, I have spent an afternoon trying to sort this out and I am sure it cannot be so difficult, but I am definitely missing something here.

Best Regards.