Skip to content
Prev 6486 / 398500 Next

Programming puzzle...

Here is a small function that was posted here some time ago by Renaud 
Lancelot in response to a similar question and which I find very handy:

Sortmat.R <- 
function (Mat, Sort) 
#  by   Renaud Lancelot <lancelot at telecomplus.sn>
#  Sort matrix or dataframe 'Mat', by column(s) 'Sort'.
#  e.g. sortmat.R(datafr, c(2,4,1))     
{
    m <- do.call("order", as.data.frame(Mat[, Sort]))
    Mat[m, ]
}
On Thu, 13 Jul 2000, Ron Wehrens wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._