| colCounts {DelayedMatrixStats} | R Documentation |
The row- and column-wise functions take either a matrix or a vector as
input. If a vector, then argument dim. must be specified and fulfill
prod(dim.) == length(x). The result will be identical to the results
obtained when passing matrix(x, nrow = dim.[1L], ncol = dim.[2L]),
but avoids having to temporarily create/allocate a matrix, if only such is
needed only for these calculations.
colCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ... ) rowCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ... ) ## S4 method for signature 'DelayedMatrix' colCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), force_block_processing = FALSE, ... ) ## S4 method for signature 'DelayedMatrix' rowCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), force_block_processing = FALSE, ... )
x |
A NxK DelayedMatrix. |
rows |
A |
cols |
A |
value |
A value to search for. |
na.rm |
|
dim. |
An |
... |
Additional arguments passed to specific methods. |
force_block_processing |
|
rowCounts() (colCounts()) returns an
integer vector of length N (K).
count() returns a scalar of type integer if
the count is less than 2^31-1 (= .Machine$integer.max) otherwise
a scalar of type double.
Peter Hickey
rowAlls
# A DelayedMatrix with a 'matrix' seed
dm_matrix <- DelayedArray(matrix(c(rep(1L, 5),
as.integer((0:4) ^ 2),
seq(-5L, -1L, 1L)),
ncol = 3))
# A DelayedMatrix with a 'DataFrame' seed
dm_DF <- DelayedArray(S4Vectors::DataFrame(C1 = rep(1L, 5),
C2 = as.integer((0:4) ^ 2),
C3 = seq(-5L, -1L, 1L)))
colCounts(dm_matrix, value = 1)
# Only count those in the first 4 rows
colCounts(dm_matrix, rows = 1:4, value = 1)
rowCounts(dm_DF, value = 5)
# Only count those in the odd-numbered rows of the 2nd column
rowCounts(dm_DF, rows = seq(1, nrow(dm_DF), 2), cols = 2, value = 5)