[R] Sorting a matrix

Erik Iverson iverson at biostat.wisc.edu
Thu Jul 10 20:34:06 CEST 2008


Do you really want to sort a *matrix*, or do you mean a data.frame?  See 
?order.

Angelo Scozzarella wrote:
> Hi,
> 
> I want to sort a matrix by a specific variable without changing the row 
> binding between variables.
> 
> Ex.
> 
> Name    Sex        Age
> Fred    M        24
> John    M        18
> Mary    F        21
> 
> 
> ordered by Age
> 
> 
> Name    Sex        Age
> John    M        18
> Mary    F        21
> Fred    M        24
> 
> 
> 
> Thanks
> 
> 
> 
> Angelo
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list