Produce an ordering permutation from a list of vectors. Essentially a non-... interface to order.

orderv(
  columns,
  ...,
  na.last = TRUE,
  decreasing = FALSE,
  method = c("auto", "shell", "radix")
)

Arguments

columns

list of atomic columns to order on, can be a data.frame.

...

not used, force later arguments to bind by name.

na.last

(passed to order) 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.

decreasing

(passed to order) logical. Should the sort order be increasing or decreasing? For the "radix" method, this can be a vector of length equal to the number of arguments in .... For the other methods, it must be length one.

method

(passed to order) the method to be used: partial matches are allowed. The default ("auto") implies "radix" for short numeric vectors, integer vectors, logical vectors and factors. Otherwise, it implies "shell". For details of methods "shell", "quick", and "radix", see the help for sort.

Value

ordering permutation

See also

Examples

d <- data.frame(x = c(2, 2, 3, 3, 1, 1), y = 6:1) d[order(d$x, d$y), , drop = FALSE]
#> x y #> 6 1 1 #> 5 1 2 #> 2 2 5 #> 1 2 6 #> 4 3 3 #> 3 3 4
d[orderv(d), , drop = FALSE]
#> x y #> 6 1 1 #> 5 1 2 #> 2 2 5 #> 1 2 6 #> 4 3 3 #> 3 3 4