So I am sorting a matrix one row at a time in descending that is 130X130, and I want to create a new matrix where the row name is the same, but the each sorted row column names are where the data was and the data in parenthesis next to the according column name. Its kind of like creating a psuedo3D array of the dimension 130x130x2 and then condensing it into a 130×130 matrix without column names. Here’s a smaller example.
Example
A B C D
A 14 82 18 50
B 39 95 27 19
C 60 40 32 15
D 70 31 69 31
This is what I want
A B(82) D(50) C(18) A(14)
B B(95) A(39) C(27) D(19)
C A(60) B(40) C(32) D(15)
D A(70) C(69) B(31) D(31)
I hope this makes sense!
Thanks!
Here you go:
First, recreate your data:
Two
apply()s, apaste()and amatrix(), and the rest is details:EDIT: Based on a comment by Jeff Allen, this can be further simplified to:
(Since this has only one
applyit should be even faster.)