This is a very embarrassing question, but I cannot understand the result of the following:
> order(c(3,1,2))
[1] 2 3 1
So, it's saying the ordered sequence is 2, 3, 1
? How?
This is a very embarrassing question, but I cannot understand the result of the following:
> order(c(3,1,2))
[1] 2 3 1
So, it's saying the ordered sequence is 2, 3, 1
? How?
> a <- c(30,10,20) # sample data
> sort(a) # sort returns your vector sorted
[1] 10 20 33
> order(a) # order returns the *indices* in the sorted vector
[1] 2 3 1
> a[order(a)] # so if you select your numbers with those indices
[1] 10 20 30 # you get your vector sorted