Skip to content
Prev 163164 / 398500 Next

Very slow: using double apply and cor.test to compute correlation p.values for 2 matrices

Out of desperation, I made the following function which hadley beats me to it :P. Thanks everyone for the great help. 
 

cor.p.values <- function(r, n) {
  df <- n - 2
  STATISTIC <- c(sqrt(df) * r / sqrt(1 - r^2))
  p <- pt(STATISTIC, df)
  return(2 * pmin(p, 1 - p))
}
_________________________________________________________________
[[elided Hotmail spam]]