dims: Get the dimensions of each element of a list-like object

dimsR Documentation

Get the dimensions of each element of a list-like object

Description

Get the dimensions, number of rows, or number of columns, of each element of a list-like object.

Note that these functions are the vectorized versions of corresponding functions dim(), nrow(), and ncol(), in the same fashion that lengths() is the vectorized version of length.

Usage

dims(x, use.names=TRUE)
nrows(x, use.names=TRUE)
ncols(x, use.names=TRUE)

Arguments

x

List-like object (or environment) where all the list elements are expected to be array-like objects with the same number of dimensions.

use.names

Logical indicating if the names on x should be propagated to the returned matrix (as its rownames) or vector (as its names).

Value

For dims(): Typically a numeric matrix with one row per list element in x and one column per dimension in these list elements (they're all expected to have the same number of dimensions). The i-th row in the returned matrix is a vector containing the dimensions of the i-th list element in x. More formally:

  dims(x)[i, ] is dim(x[[i]])

for any valid i. By default the names on x, if any, are propagated as the rownames of the returned matrix, unless use.names is set to FALSE.

For nrows() or ncols(): A numeric vector with one element per list element in x. The i-th element in the returned vector is the number of rows (or columns) of the i-th list element in x. More formally:

  nrows(x)[i] is nrow(x[[i]]) and ncols(x)[i] is ncol(x[[i]])

for any valid i. By default the names on x, if any, are propagated on the returned vector, unless use.names is set to FALSE.

See Also

  • showMethods for displaying a summary of the methods defined for a given generic function.

  • selectMethod for getting the definition of a specific method.

  • dims,DataFrameList-method in the IRanges package for an example of a specific dims method (defined for DataFrameList objects).

  • BiocGenerics for a summary of all the generics defined in the BiocGenerics package.

Examples

dims
showMethods("dims")

library(IRanges)
showMethods("dims")
selectMethod("dims", "DataFrameList")

Bioconductor/BiocGenerics documentation built on Nov. 17, 2024, 6:52 p.m.