Re: [R] Rank Function

From: David Barron <mothsailor_at_googlemail.com>
Date: Tue 10 Oct 2006 - 08:43:30 GMT

> y<-round(c(0.68,0.95,b,c,d),2)
> rank(y)

[1] 3.5 5.0 1.0 2.0 3.5

On 10/10/06, Li Zhang <zhanglitt@yahoo.com> wrote:
>
> Does anyone know why the two rank functions gives
> different results? I need to use the rank function in
> a "for" loop, so the sequence to be ranked is given
> values in the form of part (1). How can I use
> assignment like in part (1) to get correct ranks as in
> part (2)?
>
> Thank You
>
>
>
> Part (1)
> i<-1.94
> b<-0.95-i
> c<-1.73-i
> d<-2.62-i
>
> y<-c(0.68,0.95,b,c,d)
>
> y
> 0.68 0.95 -0.99 -0.21 0.68
>
> rank(y)
> 3 5 1 2 4
>
> Part(2)
> rank(c(0.68,0.95,-0.99,-0.21,0.68))
> 3.5 5.0 1.0 2.0 3.5
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

	[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Tue Oct 10 18:49:06 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 10 Oct 2006 - 09:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.