[R] Sorting in R

Thomas Lumley thomas at biostat.washington.edu
Wed Jun 21 17:40:52 CEST 2000

On Wed, 21 Jun 2000, Jim Robison-Cox wrote:

> 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:

> > Having secondary keys to break ties would be nice, as would
> > the ability to sort (in this example)
> > all 3 vectors at once.
>  That's a bit harder,  I would sort first on the secondary column, then
> the primary.  Or tertiary - secondary - primary.

If you look at the doucmentation for order() you will find that it allows
secondary and tertiary keys. There's even an example.


Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

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