R/ndim.R

##' number of dimensions
##'
##' @param a vector, matrix, or array
##' @return integer: length of dim attribute
##' @author Claudia Beleites
##' @export
ndim <- function (a){
  length (dim (a))
}

.test (ndim) <- function (){
  checkEquals (ndim (v), 0L)
  checkEquals (ndim (ensuredim (v)), 1L)
  checkEquals (ndim (m), 2L)
  checkEquals (ndim (a), 3L)
}

Try the arrayhelpers package in your browser

Any scripts or data that you put into this service are public.

arrayhelpers documentation built on Feb. 4, 2020, 3:01 a.m.