Why are you using order instead of rank?

If the data is pre sorted then they tend to give the same result (unless
there are ties), but if your data is not presorted, then the results
will be different.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -----Original Message-----
> From: Ken Williams [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, July 12, 2007 2:50 PM
> To: Greg Snow; [email protected]
> Subject: Re: [R] Compute rank within factor groups
> 
> 
> 
> 
> On 7/12/07 3:42 PM, "Ken Williams" <[EMAIL PROTECTED]> wrote:
> 
> > I ended up using:
> > 
> >  wc$rank <- ave( wc$score, wc$report,
> >                  FUN=function(x) order(x, decreasing=TRUE) )
> > 
> > Which gives me the 1-based rank integers I was looking for.
> 
> Of course, immediately after sending I realized a simpler way:
> 
>   wc$rank <- ave( -wc$score, wc$report, FUN=order )
> 
> And as a newbie I think I get to be blissfully ignorant of 
> which one is faster. =)
> 
> 
> --
> Ken Williams
> Research Scientist
> The Thomson Corporation
> Eagan, MN
> 
>

______________________________________________
[email protected] 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.

Reply via email to