Speeding up correlation matrix calculation in R

Viewed 1583

I have a dataframe with 49 variables and 4M rows. I want to calculate the correlation matrix of 49 x 49. All columns are of class numeric.

Here's a sample :

df <- data.frame(replicate(49,sample(0:50,4000000,rep=TRUE)))

I used the standard cor function.

cor_matrix <- cor(df, use = "pairwise.complete.obs")

This is taking a really long time. I have 16GB RAM and an i5 single core 2.60Ghz.

Is there a way to make this calculation faster on my desktop?

1 Answers
Related