Do you know an R function that sort each column of a matrix without using apply like this:
mat= matrix(c(1,2,0,-7,-4,7,8,3,12,15,23,-21),nrow = 4,ncol = 3)
apply(mat,2,sort)
##
[,1] [,2] [,3]
[1,] -7 -4 -21
[2,] 0 3 12
[3,] 1 7 15
[4,] 2 8 23
Do you also know a R function that return a vector of max of each column of a matrix without using apply like this?
mat2=matrix(c(2,1,0,-7,-4,7,8,3,12,15,23,-21),nrow = 3,ncol = 4)
apply(mat2,2,max)
##
[1] 2 7 12 23
Thanks.