I have a large correlation matrix result in R – for now about 30 items correlated against each other – so the array has about 10,000 cells. I want to find the largest 5 and smallest 5 results. How can I do this?
Here’s what a very small portion – the upper left corner – looks like:
PL1 V3 V4 V5
PL1 1.00000000 0.19905701 -0.02994034 -0.1533846
V3 0.19905701 1.00000000 0.09036472 0.1306054
V4 -0.02994034 0.09036472 1.00000000 0.1848030
V5 -0.15338465 0.13060539 0.18480296 1.0000000
The values in the table are always between 1 & -1 and if it helps, being a correlation matrix the upper half above the diagonal is a duplicate of the lower half below the diagonal.
I need the most positive 5 less than 1 and the most negative 5 including -1 if it exists.
Thanks in advance.
You want to find the largest and smallest correlations and probably know not only what, but where those values came from. It’s easy.