rowMins: Calculates the minimum for each row (column) of a matrix-like...

Description Usage Arguments Details Value See Also Examples

Description

Calculates the minimum for each row (column) of a matrix-like object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ...)

## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric'
rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ...)

## S4 method for signature 'ANY'
rowMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ...)

colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ...)

## S4 method for signature 'matrix_OR_array_OR_table_OR_numeric'
colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, dim. = dim(x), ...)

## S4 method for signature 'ANY'
colMins(x, rows = NULL, cols = NULL, na.rm = FALSE, ...)

Arguments

x

An NxK matrix-like object.

rows, cols

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

na.rm

If TRUE, NAs are excluded first, otherwise not.

...

Additional arguments passed to specific methods.

dim.

An integer vector of length two specifying the dimension of x, essential when x is a numeric vector. Note, that this is not a generic argument and not all methods need provide it.

Details

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

Value

Returns a numeric vector of length N (K).

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  mat <- matrix(rnorm(15), nrow = 5, ncol = 3)
  mat[2, 1] <- NA
  mat[3, 3] <- Inf
  mat[4, 1] <- 0
  
  print(mat)
  
  rowMins(mat)
  colMins(mat)
  

Example output

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.3719395 -0.31669563 -0.2419946
[2,]         NA  0.59290237 -0.9594698
[3,]  0.5659424  2.23957030        Inf
[4,]  0.0000000  0.07755812 -0.2760817
[5,] -0.7778717 -0.01776258  0.3031428
[1] -0.3719395         NA  0.5659424 -0.2760817 -0.7778717
[1]         NA -0.3166956 -0.9594698

MatrixGenerics documentation built on Feb. 1, 2021, 2:01 a.m.