colOrderStats-dgCMatrix-method: Calculates an order statistic for each row (column) of a...

Description Usage Arguments Details Value See Also Examples

Description

Calculates an order statistic for each row (column) of a matrix-like object.

Usage

1
2
3
4
5
## S4 method for signature 'dgCMatrix'
colOrderStats(x, rows = NULL, cols = NULL, which = 1, na.rm = FALSE)

## S4 method for signature 'dgCMatrix'
rowOrderStats(x, rows = NULL, cols = NULL, which = 1, na.rm = FALSE)

Arguments

x

An NxK matrix-like object.

rows

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

cols

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

which

An integer index in [1,K] ([1,N]) indicating which order statistic to be returned

na.rm

If TRUE, NAs are excluded first, otherwise not.

Details

The S4 methods for x of type matrix, array, or numeric call matrixStats::rowOrderStats / matrixStats::colOrderStats.

Value

Returns a numeric vector of length N (K).

See Also

Examples

1
2
3
4
5
6
7
8
9
mat <- matrix(rnorm(15), nrow = 5, ncol = 3)
    mat[2, 1] <- 2
    mat[3, 3] <- Inf
    mat[4, 1] <- 0
    
    print(mat)
    
    rowOrderStats(mat, which = 1)
    colOrderStats(mat, which = 3)

Example output

Loading required package: MatrixGenerics
Loading required package: matrixStats

Attaching package:MatrixGenericsThe following objects are masked frompackage: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,]  0.1583615  0.2704270  1.2541778
[2,]  2.0000000  1.2665525 -1.4995291
[3,]  0.6899651 -0.5106760        Inf
[4,]  0.0000000  0.4842335 -1.3416163
[5,] -0.8845643 -1.1153721 -0.6899365
[1]  0.1583615 -1.4995291 -0.5106760 -1.3416163 -1.1153721
[1]  0.1583615  0.2704270 -0.6899365

sparseMatrixStats documentation built on Feb. 4, 2021, 2 a.m.