nr: Convenience functions for rows or columns manipulations.

nrR Documentation

Convenience functions for rows or columns manipulations.

Description

'nr()' and 'nc()' are synonyms of the ugly 'NROW()' or 'NCOL()' that still provide a result, even if 'dim' attribute of the object is not set, on the contrary to 'nrow()'or 'ncol()'. 'ROWS' and 'COLS' are constants that makes call to 'apply()' more expressive.

Usage

nr(x)

nc(x)

ROWS

COLS

Arguments

x

Any object.

Format

An object of class numeric of length 1.

An object of class numeric of length 1.

See Also

[NROW()]

Examples

mm <- matrix(1:6, nrow = 3)
nr(mm)
nc(mm)
vv <- 1:6
nr(vv)
nc(vv)
# ROWS and COLS constants used with apply()
apply(mm, ROWS, mean) # Idem apply(mm, 1, mean)
apply(mm, COLS, mean) # Idem apply(mm, 2, mean)

SciViews documentation built on June 8, 2025, 1:52 p.m.