[R] about the function order()
laurent at cbs.dtu.dk
Sat Nov 24 20:45:27 CET 2001
Thomas Lumley wrote:
> On Sat, 24 Nov 2001, Laurent Gautier wrote:
> > 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)
> >  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)
> >  4 2 1 3
> > >
> > > a <- rnorm(50)
> > > plot(a, order(a)/50)
> > My question is, what is really order() doing ?
> In a sense it's doing the opposite of what you thought.
You are perfectly right.... How amazing things once clear blur with
I guess I should go home and rest before doing anything else silly... =)
Thanks for being around on a saturday and giving a fast answer...
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