Learn R Programming

tester (version 0.2.0)

has_dimension: Has dimension?

Description

has_dimension and has_dim test if an object has dimension (i.e. dim)
lacks_dimension and lacks_dim test if an object lacks dimension

Usage

has_dimension(x)

Arguments

x

an R object

Examples

Run this code
m = matrix(1:12, 4, 3)
a = as.array(letters)
has_dim(m) # TRUE
has_dimension(a)

has_dimension(iris) # TRUE

has_dim(matrix(1:10, 10, 1)) # TRUE
has_dim(matrix(1:10, 1, 10)) # TRUE

has_dim(1) # FALSE
lacks_dim(1) # TRUE
has_dim(1:10) # FALSE
has_dimension("dimension") # FALSE

Run the code above in your browser using DataLab