[R] Calculating correlation for a big matrix
Charles C. Berry
cberry at tajo.ucsd.edu
Fri Nov 21 04:02:58 CET 2008
On Thu, 20 Nov 2008, A Ezhil wrote:
> Dear All,
> I have a matrix of size 10000 x 50. I would like to calculate all
> possible pair-wise correlation coefficient (5x10^7 combinations) using
> cor(). How can I efficiently calcualte and save the result in a matrix?
By using cor()??
res <- cor( t( mat ) )
only takes about 10 seconds on my laptop.
To save() the result takes much longer as does load()ing the result back
into fresh session. Save 'mat' instead and do the calculation on the fly
p.s. please read the Posting Guide and do not repost the same msg.
> Thanks in advance.
> Kind regards,
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help