Actually, I've answered my own question. It turns out that transposing the expression matrix first, outside of the loop, significantly improves the speed. It now looks like the entire matrix should be calculated in a day or two. So I think this solution should be fine.
I now have this: expression.data<-t(expression.data) for (j in 1:dim(genes2)[1]){ for(i in 1:dim(genes1)[1]){ peak1<-as.vector(expression.data[genes1[i,1],]) peak2<-as.vector(expression.data[genes2[j,1],]) Cor.matrix[i,j]<-cor(peak1,peak2,method='s') } } Thanks for reading. Alayne ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.