Is there any way to sort columns of a matrix independently in R?

后端 未结 1 1656
不思量自难忘°
不思量自难忘° 2021-01-02 09:43

I\'m a newbie in R so, I really need some help here. I just want to sort each column independently. Any help is appreciated!

 > mat <- matrix(c(45,34,1         


        
相关标签:
1条回答
  • 2021-01-02 10:45

    Yes, there is!

    apply(mat, 2, sort)
         [,1] [,2] [,3]
    [1,]    1    1    2
    [2,]    3    2    3
    [3,]   34    5    4
    [4,]   45    7   32
    [5,] 4325   23  734
    
    0 讨论(0)
提交回复
热议问题