Order: Order: Order Items Using Columns Of A Data.Frame As Keys

Description Usage Arguments Details Value Author(s)

View source: R/Order.R

Description

Order augments the base order() function to work with data.frames, lists, etc.

Usage

1
Order(sort.on, ..., na.last = T, decreasing = F)

Arguments

sort.on

a data.frame, list, matrix, 2D-array, table or vector. If sort.on is a list, all elements must be vectors of the same length. All other classes will be coerced to list. The first element in the list will used for sorting; additional elements (if supplied) will be used to break ties.

...

additional vector arguments, all of the same length (which must be equal to the number of rows of sort.on). This argument permits Order to be called in the same manner as the base order() function.

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.

decreasing

logical. Should the sort order be increasing or decreasing?

Details

This function is just a wrapper for link{order} that permits it to be called with more complex objects. For example, if you wanted to sort a data.frame x based on the contents of its first three columns...

> Order(x)

... would give the same result as:

> order(x[, 1], x[, 2], x[, 3])

Value

a vector of integers specifying the permutation that will result in ordering of the elements of sort on

Author(s)

M.W.Rowe, mwr.stats@gmail.com


mwrowe/microRutils documentation built on June 12, 2021, 2:41 p.m.