Suppose I have a distance matrix "m":
0 1 2 4 5 6 7 8 9 10
0 0.00000 1.68980 7.55815 4.18765 4.48060 4.41775 3.97950 4.12830 4.25500 4.48110
1 1.68980 0.00000 7.67225 4.11300 4.48225 4.62525 3.92880 4.02495 4.19675 4.46860
2 7.55815 7.67225 0.00000 7.31290 7.23675 7.46935 7.29925 7.41055 7.43290 7.28585
4 4.18765 4.11300 7.31290 0.00000 3.81510 3.35225 2.88600 3.29000 3.01940 3.94900
5 4.48060 4.48225 7.23675 3.81510 0.00000 4.29490 3.66205 4.00220 3.70005 2.34825
6 4.41775 4.62525 7.46935 3.35225 4.29490 0.00000 3.42355 3.63880 2.27245 4.23745
7 3.97950 3.92880 7.29925 2.88600 3.66205 3.42355 0.00000 2.48115 2.97045 3.61370
8 4.12830 4.02495 7.41055 3.29000 4.00220 3.63880 2.48115 0.00000 2.97630 3.92015
9 4.25500 4.19675 7.43290 3.01940 3.70005 2.27245 2.97045 2.97630 0.00000 3.80345
10 4.48110 4.46860 7.28585 3.94900 2.34825 4.23745 3.61370 3.92015 3.80345 0.00000
I would like to know which col/row names cause values above 5.
I tried:
> m[which(m > 5)]
[1] 7.55815 7.67225 7.55815 7.67225 7.31290 7.23675 7.46935 7.29925 7.41055 7.43290 7.28585 7.31290 7.23675 7.46935 7.29925 7.41055
[17] 7.43290 7.28585
But this returns only the values.
When I try:
> colnames(m[which(m > 5)])
I get NULL
In this example, I am trying to catch "2" which responsible for values above 5.