[R] Question about base::rank results

J Robertson-Burns robertsonburns at btinternet.com
Mon Apr 27 21:34:05 CEST 2015


There is a blog post on this topic:

http://www.portfolioprobe.com/2012/07/26/r-inferno-ism-order-is-not-rank/

Pat

On 26/04/2015 09:17, Giorgio Garziano wrote:
> Hi,
>
> I cannot understand why rank(x) behaves as outlined below.
> Based on the results of first x vector values ranking, which is as expected in my opinion,
> I cannot explain the following results.
>
>> x <- c(12,34,15,77,78)
>> x[rank(x)]
> [1] 12 15 34 77 78      (OK)
>
>> x <- c(12,34,15,77,78,22)
>> x[rank(x)]
> [1] 12 77 34 78 22 15   (?)
>
>> x <- c(12,34,77,15,78)
>> x[rank(x)]
> [1] 12 77 15 34 78      (?)
>
> Please any feedback ? Thanks.
>
> BR,
>
> Giorgio Garziano
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



More information about the R-help mailing list