Skip to content
Prev 278372 / 398506 Next

Correlation matrix removing insignificant R values

Looking over the code below, I think this patched version might return
a better answer:

spec.cor <- function(dat, r, ...) {
    x <- cor(dat, ...)
    x[upper.tri(x, TRUE)] <- NA
    i <- which(abs(x) >= r, arr.ind = TRUE)
    data.frame(V1 = rownames(x)[i[,1]], V2 = colnames(x)[i[,2]], Value = x[i])
}

On Thu, Nov 24, 2011 at 12:03 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote: