logical. Should the sort sort be increasing or
decreasing?
na.last
for controlling the treatment of NAs. If
TRUE, missing
values in the data are put last; if FALSE, they are put
first; if NA, they are removed (see the Notes in
sort)
Value
vector of length to-from+1.
Details
The smaller the difference to-from is
compared to the length of x, the
faster is sortx compared to sort.
Particularly, sortx(..., from=k, to=k)
is much faster than sort(...)[k].
# NOT RUN {x <- runif(10^6)
k <- 10
system.time(y<-sort(x)[1:k])
system.time(z<-sortx(x, from=1, to=k)) ## much fasterstopifnot(all(y == z)) ## same result# }