order {statnet.common} | R Documentation |
sort
and order
methods for
data.frame
and matrix
, sorting it in
lexicographic order.These function return a data frame sorted in lexcographic order or a permutation that will rearrange it into lexicographic order: first by the first column, ties broken by the second, remaining ties by the third, etc..
order(..., na.last = TRUE, decreasing = FALSE) ## Default S3 method: order(..., na.last = TRUE, decreasing = FALSE) ## S3 method for class 'data.frame' order(..., na.last = TRUE, decreasing = FALSE) ## S3 method for class 'matrix' order(..., na.last = TRUE, decreasing = FALSE) ## S3 method for class 'data.frame' sort(x, decreasing = FALSE, ...)
... |
Ignored for |
na.last |
See |
decreasing |
Whether to sort in decreasing order. |
x |
A |
For sort
, a data frame, sorted lexicographically. For
order
, a permutation I
(of a vector 1:nrow(x)
) such
that x[I,,drop=FALSE]
equals x
ordered lexicographically.
data.frame
, sort
, order
,
matrix
data(iris) head(iris) head(order(iris)) head(sort(iris)) stopifnot(identical(sort(iris),iris[order(iris),]))