[R] A problem with order() function in R

Bert Gunter bgunter.4567 at gmail.com
Tue Jul 18 07:06:09 CEST 2017

You need to study ?order and perhaps also subscripting. If that isn't
sufficient, I suggest you consult one of the many R web tutorials that
cover this.

Perhaps this will help:

x[order(x)]  gives x in sorted order, which is what you woud get with
sort(x). Indeed, the code implementing sort.default(x) is essentially
x[order(x)] !

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Jul 17, 2017 at 7:58 PM, Jesadaporn Pupantragul
<jp.beckmcs at gmail.com> wrote:
> Hello r-help
> I am learning R and use R-studio.
> I create vector x <- c(19,17,23,11) and use function order(x).
> The result show [1]  4 2 1 3. Why it doesn't show [1] 3 2 4 1.
> Follow picture that i attach.
> Thank you for you answer.
> ______________________________________________
> 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