[R] about the function order()

Laurent Gautier laurent at cbs.dtu.dk
Sat Nov 24 19:59:36 CET 2001


Dear all,


I have recently experienced something with the function order I cannot
explain:


The help(order) (which I admit having overlooked before) rises even more
my confusion...

The following lines made me think order() was returning the 'order' each
value in a vector would take when sorted.
 
> a <- c(4.1, 3.2, 6.1)
> order(a)
[1] 2 1 3

Doing
> plot(a, order(a)/length(a))
gave what I expected (an empirical distribution function).



Hower the following made me think I have been misusing order():

> a <- c(4.1, 3.2, 6.1, 3.1)
> order(a)
[1] 4 2 1 3
>
> a <- rnorm(50)
> plot(a, order(a)/50)

My question is, what is really order() doing ?
(This question is like asking for RTFMs... I have no problem with that,
I just could not find much in the pdf about R I had).



Thanking in advance an help,



Laurent





-- 
Laurent Gautier			CBS, Building 208, DTU
PhD. Student			D-2800 Lyngby,Denmark	
tel: +45 45 25 24 85		http://www.cbs.dtu.dk/laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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