colMaxs: Maximum/minimum values in columns or rows

View source: R/utils.R

colMaxsR Documentation

Maximum/minimum values in columns or rows

Description

Produce the same result as apply(x, 2, max), apply(x, 1, max), apply(x, 2, min) and apply(x, 1, min), respectively, but ignore NA.

Usage

colMaxs(x, use_nan = FALSE)

rowMaxs(x, use_nan = FALSE)

colMins(x, use_nan = FALSE)

rowMins(x, use_nan = FALSE)

Arguments

x

a base::matrix or Matrix::Matrix object.

use_nan

if TRUE, return NaN for columns or rows with all zero. Only used when x is a sparse matrix.

Value

a numeric vector

Examples

  mt <- Matrix::rsparsematrix(100, 100, 0.9)
  colMaxs(mt)
  apply(mt, 2, max) # the same

proxyC documentation built on Oct. 30, 2026, 9:08 a.m.