File: colRanks-dgCMatrix-method.Rd

package info (click to toggle)
r-bioc-sparsematrixstats 1.10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,024 kB
  • sloc: cpp: 1,602; makefile: 2
file content (94 lines) | stat: -rw-r--r-- 3,059 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods.R, R/methods_row.R
\name{colRanks,dgCMatrix-method}
\alias{colRanks,dgCMatrix-method}
\alias{rowRanks,dgCMatrix-method}
\title{Calculates the rank of the elements for each row (column) of a matrix-like
object}
\usage{
\S4method{colRanks}{dgCMatrix}(
  x,
  rows = NULL,
  cols = NULL,
  ties.method = c("max", "average", "min"),
  preserveShape = FALSE,
  na.handling = c("keep", "last"),
  ...,
  useNames = NA
)

\S4method{rowRanks}{dgCMatrix}(
  x,
  rows = NULL,
  cols = NULL,
  ties.method = c("max", "average", "min"),
  preserveShape = TRUE,
  na.handling = c("keep", "last"),
  ...,
  useNames = NA
)
}
\arguments{
\item{x}{An NxK matrix-like object.}

\item{rows}{A \code{\link{vector}} indicating the subset of rows
(and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is
done.}

\item{cols}{A \code{\link{vector}} indicating the subset of rows
(and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is
done.}

\item{ties.method}{A character string specifying how ties are treated. Note
that the default specifies fewer options than the original matrixStats
package.}

\item{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()`.}

\item{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}

\item{...}{Additional arguments passed to specific methods.}

\item{useNames}{If \code{\link{NA}}, the default behavior of the function about naming support is remained. If \code{\link{FALSE}}, no naming support is done. Else if \code{\link{TRUE}}, names attributes of result are set.}
}
\value{
a matrix of type \code{\link{integer}} is returned unless
\code{ties.method = "average"}. Ithas dimensions` \code{NxJ} (\code{KxJ})
\code{\link{matrix}}, where N (K) is the number of rows (columns) of the
input x.
}
\description{
Calculates the rank of the elements for each row (column) of a matrix-like
object.
}
\details{
There are three different methods available for handling ties:
   \describe{
     \item{`max`}{for values with identical values the maximum rank is returned}
     \item{`average`}{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`.}
     \item{`min`}{for values with identical values the minimum rank is returned.}
   }
}
\examples{
mat <- matrix(rnorm(15), nrow = 5, ncol = 3)
  mat[2, 1] <- NA
  mat[3, 3] <- Inf
  mat[4, 1] <- 0
  
  print(mat)
  
  rowRanks(mat)
  colRanks(mat)
}
\seealso{
\itemize{
\item \code{matrixStats::\link[matrixStats]{rowRanks}()} and
\code{matrixStats::\link[matrixStats:rowRanks]{colRanks}()} which are used
when the input is a \code{matrix} or \code{numeric} vector.
\item \link[base:rank]{base::rank}
}
}