DIM: Helpers for working with 1-d arrays

Description Usage Arguments Value Examples

View source: R/utils.R

Description

DIM() is to dim() as NROW() is to nrow(). That is, it is identical to dim() in most cases except if the input is a bare atomic vector with no dim attribute, in which case, the length of the vector is returned instead of NULL.

DROP first calls base::drop and then completely removes the dim attribute if the result is a 1-d array

Usage

1
2
3
DIM(x)

DROP(x)

Arguments

x

an R vector, potentially with a dim attribute

Value

For DIM, the dim attribute, or if that's not found, then length(x)

For DROP an array with 2 or more axes, or a vector with no dim attributes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- 1:3
dim(x)
dim(array(x))

DIM(x)
DIM(array(x))

x <- array(1:3)
str(drop(x))
str(DROP(x))

listarrays documentation built on March 26, 2020, 6:10 p.m.