Description Usage Arguments Details Value See Also Examples
Calculates the rank of the elements for each row (column) of a matrix-like object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## S4 method for signature 'dgCMatrix'
colRanks(
x,
rows = NULL,
cols = NULL,
ties.method = c("max", "average", "min"),
preserveShape = FALSE,
na.handling = c("keep", "last")
)
## S4 method for signature 'dgCMatrix'
rowRanks(
x,
rows = NULL,
cols = NULL,
ties.method = c("max", "average", "min"),
preserveShape = TRUE,
na.handling = c("keep", "last")
)
|
x |
An NxK matrix-like object. |
rows |
A |
cols |
A |
ties.method |
A character string specifying how ties are treated. Note that the default specifies fewer options than the original matrixStats package. |
preserveShape |
a boolean that specifies if the returned matrix has the same dimensions as the input matrix. By default this is true for 'rowRanks()', but false for 'colRanks()'. |
na.handling |
string specifying how 'NA's are handled. They can either be preserved with an 'NA' rank ('keep') or sorted in at the end ('last'). Default is 'keep' derived from the behavior of the equivalent |
There are three different methods available for handling ties:
for values with identical values the maximum rank is returned
for values with identical values the average of the ranks they cover is returned. Note, that in this case the return value is of type 'numeric'.
for values with identical values the minimum rank is returned.
a matrix of type integer
is returned unless
ties.method = "average"
. Ithas dimensions' NxJ
(KxJ
)
matrix
, where N (K) is the number of rows (columns) of the
input x.
matrixStats::rowRanks()
and
matrixStats::colRanks()
which are used
when the input is a matrix
or numeric
vector.
base::rank
1 2 3 4 5 6 7 8 9 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.