check-scalar-hasDims: Does the input have dimensions?

check-scalar-hasDimsR Documentation

Does the input have dimensions?

Description

Does the input have dimensions?

Usage

hasDims(x, n = NULL)

hasRows(x, n = NULL)

hasCols(x, n = NULL)

Arguments

x

Object.

n

integer or NULL. Expected dimension number. For hasDims, integer(2) is required, corresponding to rows, columns. If NULL, only checks for non-zero dimensions.

Value

TRUE on success; FALSE on failure, with cause set.

Note

Updated 2023-10-06.

See Also

  • dim() or BiocGenerics::dims() for DFrameList.

  • nrow() or BiocGenerics::nrows() for DFrameList.

  • ncol() or BiocGenerics::ncols() for DFrameList.

  • assertive.properties::has_dims().

  • assertive.properties::has_rows().

  • assertive.properties::has_cols().

Examples

## TRUE ====
x <- datasets::mtcars
hasDims(x)
hasRows(x)
hasCols(x)

## Note that dims don't have to be non-zero, just not NULL.
hasDims(data.frame())

## Expected dimension number is supported.
x <- matrix(data = seq(from = 1L, to = 6L), nrow = 3L, ncol = 2L)
## For `hasDims`, `n` corresponds to rows, columns.
hasDims(x, n = c(3L, 2L))
hasRows(x, n = 3L)
hasCols(x, n = 2L)

## FALSE ====
x <- data.frame()
hasDims(list())
hasRows(x)
hasCols(x)

acidgenomics/goalie documentation built on Dec. 11, 2023, 11:36 p.m.