[Rd] rank (PR#7850)
stella.david at math.uni-augsburg.de
stella.david at math.uni-augsburg.de
Wed May 11 12:01:04 CEST 2005
Full_Name: Stella David
Version: 2.1.0
OS: mingw32
Submission from: (NULL) (137.250.161.136)
It seems that rank doesn't work right on vectors containing negative values.
If the negative value is the first component or there are only two components,
it works, but if the negative value is somewhere in the middle there's a
problem.
Here are my examples:
> # wrong:
> x<- c(2,-5,1,3);x
[1] 2 -5 1 3
> rank(x)
[1] 3 1 2 4
> x[rank(x)]
[1] 1 2 -5 3
>
> # but this works:
> y<- c(-5,2,1,3);y
[1] -5 2 1 3
> rank(y)
[1] 1 3 2 4
> y[rank(y)]
[1] -5 1 2 3
> z <- c(3,-5);z
[1] 3 -5
> rank(z)
[1] 2 1
> z[rank(z)]
[1] -5 3
>
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 1.0
year 2005
month 04
day 18
language R
Stella David
More information about the R-devel
mailing list