Description Usage Arguments Value Note See Also Examples
order
returns a permutation which rearranges its first argument
into ascending or descending order, breaking ties by further
arguments.
NOTE: This man page is for the order
S4 generic function
defined in the BiocGenerics package.
See ?base::order
for the default method
(defined in the base package).
Bioconductor packages can define specific methods for objects
(typically vector-like) not supported by the default method.
1 |
... |
One or more vector-like objects, all of the same length. |
na.last, decreasing, method |
See |
The default method (see ?base::order
) returns
an integer vector of length N where N is the common length of the
input objects. This integer vector represents a permutation of N
elements and can be used to rearrange the first argument in
...
into ascending or descending order (by subsetting it).
Specific methods defined in Bioconductor packages should also return an integer vector representing a permutation of N elements.
TO DEVELOPERS:
Specific order
methods should preferably be made "stable" for
consistent behavior across platforms and consistency with
base::order()
. Note that C qsort() is not "stable" so
order
methods that use qsort() at the C-level need to ultimately
break ties by position, which can easily be done by adding a little
extra code at the end of the comparison function passed to qsort().
order(x, decreasing=TRUE)
is not always equivalent to
rev(order(x))
.
order
, sort
,
and rank
methods for specific vector-like
objects should adhere to the same underlying order that should be
conceptually defined as a binary relation on the set of all possible
vector values. For completeness, this binary relation should also be
incarnated by a <= method.
base::order
for the default order
method.
showMethods
for displaying a summary of the
methods defined for a given generic function.
selectMethod
for getting the definition of
a specific method.
order,IntegerRanges-method in the IRanges
package for an example of a specific order
method (defined
for IntegerRanges objects).
BiocGenerics for a summary of all the generics defined in the BiocGenerics package.
1 2 3 | order
showMethods("order")
selectMethod("order", "ANY") # the default method
|
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit, which, which.max, which.min
standardGeneric for "order" defined from package "BiocGenerics"
function (..., na.last = TRUE, decreasing = FALSE, method = c("shell",
"radix"))
standardGeneric("order")
<environment: 0x419dc38>
Methods may be defined for arguments: ...
Use showMethods("order") for currently available ones.
Function: order (package BiocGenerics)
...="ANY"
Method Definition (Class "derivedDefaultMethod"):
function (..., na.last = TRUE, decreasing = FALSE, method = c("shell",
"radix"))
{
z <- list(...)
if (missing(method)) {
ints <- all(vapply(z, function(x) is.integer(x) || is.factor(x),
logical(1L)))
method <- if (ints)
"radix"
else "shell"
}
else {
method <- match.arg(method)
}
if (any(unlist(lapply(z, is.object)))) {
z <- lapply(z, function(x) if (is.object(x))
as.vector(xtfrm(x))
else x)
if (method == "radix" || !is.na(na.last))
return(do.call("order", c(z, na.last = na.last, decreasing = decreasing,
method = method)))
}
else if (method != "radix" && !is.na(na.last)) {
return(.Internal(order(na.last, decreasing, ...)))
}
if (method == "radix") {
decreasing <- rep_len(as.logical(decreasing), length(z))
return(.Internal(radixsort(na.last, decreasing, FALSE,
TRUE, ...)))
}
if (any(diff((l.z <- lengths(z)) != 0L)))
stop("argument lengths differ")
na <- vapply(z, is.na, rep.int(NA, l.z[1L]))
ok <- if (is.matrix(na))
rowSums(na) == 0L
else !any(na)
if (all(!ok))
return(integer())
z[[1L]][!ok] <- NA
ans <- do.call("order", c(z, decreasing = decreasing))
ans[ok[ans]]
}
<environment: namespace:base>
Signatures:
...
target "ANY"
defined "ANY"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.