[R] Sorting in R

gb gb at stat.umu.se
Wed Jun 21 16:44:54 CEST 2000


On Wed, 21 Jun 2000, Art Salwin wrote:

> How do you sort one vector using another vector as a sort
> key?  Sort of equivalent
> to sorting rows of a spreadsheet using one of its columns as
> key.  Here's a simple example:
> 
> name<-c("Joe","Sue","Mary")
> age<-c(22, 57, 13)
> zipcode<-(50854, 20617, 91234)
> If we sort the name vector in zipcode order we should get
> mary, joe, sue
> If we sort name in age order we should get sue, joe, mary
> Having secondary keys to break ties would be nice, as would
> the ability to sort (in this example)
> all 3 vectors at once.
> 
> Any help appreciated.
> 

Try

> ?order

Goran

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list