Description Usage Arguments Details Value See Also Examples
Count how often an element in a row (column) of a matrix-like object is equal to a value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ...)
## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric'
rowCounts(x, rows = NULL,
cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ...)
## S4 method for signature 'ANY'
rowCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ...)
colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ...)
## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric'
colCounts(x, rows = NULL,
cols = NULL, value = TRUE, na.rm = FALSE, dim. = dim(x), ...)
## S4 method for signature 'ANY'
colCounts(x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, ...)
|
x |
An NxK matrix-like object. |
rows, cols |
A |
value |
The value to search for. |
na.rm |
If |
... |
Additional arguments passed to specific methods. |
dim. |
An |
The S4 methods for x
of type matrix
,
array
, or numeric
call
matrixStats::rowCounts
/ matrixStats::colCounts
.
Returns a integer
vector
of length N (K).
matrixStats::rowCounts()
and
matrixStats::colCounts()
which are
used when the input is a matrix
or numeric
vector.
For checks if any element is equal to a value, see
rowAnys()
. To check if all elements are equal, see
rowAlls()
.
1 2 3 4 5 6 7 8 9 10 11 12 |
Loading required package: matrixStats
Attaching package: ‘MatrixGenerics’
The following objects are masked from ‘package:matrixStats’:
colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
colWeightedMeans, colWeightedMedians, colWeightedSds,
colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
rowWeightedSds, rowWeightedVars
[,1] [,2] [,3]
[1,] -3.4025439 0.3485589 -0.13260130
[2,] NA 0.6789007 -0.08482346
[3,] 1.5749983 1.1703291 Inf
[4,] 0.0000000 -1.1609493 0.89429373
[5,] -0.7854997 -0.3576996 -0.01277892
[1] 0 NA 0 0 0
[1] NA 0 0
[1] 0 NA 0 1 0
[1] 0 0 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.