I have created a correlation matrix in R using:
cor(df, use = "p")->df_corr
Then I melted the matrix using:
melt(df_corr) -> df_corr_melted
to get:
Var1 Var2 value
A B .1
A C .2
A A 1
B A .1
B C .4
B B 1
C A .2
C B .4
C C 1
I'd like to remove the redudnant pairs. For example, I only need corr(A,C) not corr(C,A). I read through the filtering commands in dplyr, but since the row combination is actually unique, these aren't true duplicates. Any suggestions?
filterwithdplyr) whereVar1 <= Var2. Use<instead of<=if you want to also omit the trivial X,X correlations. - Gregor Thomas