Off topic:How to sort all the columns all together of a dataframe using R?
1
0
Entering edit mode
8.6 years ago
Paul ▴ 80

I would like to sort in descending order all columns of data.frame. The dataframe looks like

mat

.      [,D1]  [,D2]  [,Dn]
[D1,]  5      1      6
[D2,]  10     3      1
[D3,]  8      8      1
[D4,]  8      9      9
[D5,]  3      7      3
[D6,]  8      8      5
[D7,]  10     10     2
[D8,]  8      10     7
[D9,]  10     1      9
[Dn,]  9      4      5

I know to sort it based on a single column by using mat <- mat[order(mat$D1),], but I have 1000 columns. How do I sort all 1000 keeping the row name same.

R • 4.0k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2646 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6