[R] Sorted index of values in matrix

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Apr 15 17:11:37 CEST 2022


В Fri, 15 Apr 2022 14:53:36 +0000
Eliza Botto <eliza_botto using outlook.com> пишет:

> sort(qq) command will execute the sorted values of this matrix as (1
> 2 3 4 5 6). Instead of values, I want the row and column names of
> these sorted values as (1,1), (1,2), (1,3), (2,1), (2,2), (2,3)

Combine order() to get the sorting permutation with arrayInd() to get
row and column indices from absolute indices with colnames() and
rownames() to get the names themselves.

-- 
Best regards,
Ivan



More information about the R-help mailing list