[R] Sorting in R

About this list Date view Thread view Subject view Author view Other groups

Subject: [R] Sorting in R
From: Art Salwin (salwin@mitretek.org)
Date: Thu 22 Jun 2000 - 00:36:38 EST


Message-ID: <3950D2F6.F057C89F@mitretek.org>

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.

-- 
Art Salwin
salwin@mitretek.org
(202) 863-2985
(202) 863-2988 (fax)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:23 EST