Why is plyr so slow?

Why it is so slow? A little research located a mail group posting from a Aug. 2011 where @hadley, the package author, states This is a drawback of the way that ddply always works with data frames. It will be a bit faster if you use summarise instead of data.frame (because data.frame is very slow), … Read more

Is there a R function that applies a function to each pair of columns?

It wouldn’t be faster, but you can use outer to simplify the code. It does require a vectorized function, so here I’ve used Vectorize to make a vectorized version of the function to get the correlation between two columns. df <- data.frame(x=rnorm(100),y=rnorm(100),z=rnorm(100)) n <- ncol(df) corpij <- function(i,j,data) {cor.test(data[,i],data[,j])$p.value} corp <- Vectorize(corpij, vectorize.args=list(“i”,”j”)) outer(1:n,1:n,corp,data=df)