Can someone explain to me how to correctly write the panel.cor
function to get the labels for pairwise correlations of the columns of the matrix (my_matrix) supplied to the pairs
function?
par(mfrow=c(1,1))
pairs(my_matrix,
upper.panel = panel.cor,
panel = function(...) smoothScatter(..., nbin=64,
nrpoints = 0,
add = TRUE), gap = 0.2, ylim = c(-5,5), xlim=c(-5,5)
)
panel.cor <- function(x, y, digits=3, prefix="", ...) {
r <- cor(x,y)
}
The function supplied to the panel
argument is from the examples section of the smoothScatter
help page.