I want to calculate correlation matrix P which each P[i,j] is correlation coefficient of row i and col j in matrix Data. for example
Data <- matrix(rnorm(500),50,10)
P <- matrix(0,50,50)
for (i in 1:50)
for(j in 1:50)
P[i,j] <- cor(Data[i,],Data[j,])
But how can I use apply or something like this command to calculate such correlations.