I am trying to find the strongest correlation between two data sets in R and one set has 9000+ columns. I used cor() and it worked well, but is there a function or way to find the strongest correlation value and column name? Note that I do have many NA values in the correlation matrix, but this is to be expected for my situation. Any advice would be really appreciated.
$\begingroup$
$\endgroup$
2
-
1$\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$Community– Community Bot2022-11-21 04:18:22 +00:00Commented Nov 21, 2022 at 4:18
-
$\begingroup$ What about the other set? $\endgroup$utobi– utobi2022-11-21 05:45:16 +00:00Commented Nov 21, 2022 at 5:45
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
I have some experience with this question, but it may not be the best. Suppose the correlation coefficient is stored in corr_df(a data frame [9000,1])
Try this code:
corr_df[order(corr_df[,1],decreasing = TRUE),]
It can rank the magnitude of the correlation coefficients from high to low, and also get the row(or col) for corresponding coefficient specifi.
I hope it will be helpful to you.