R/assertive.properties_utils.R

Defines functions n_elements DIM

#' @author Richard Cotton <richierocks@gmail.com>
#' @noRd
DIM <- function(x)
{
  dim_x <- dim(x)
  if(is.null(dim_x)) length(x) else dim_x
}

#' @author Richard Cotton <richierocks@gmail.com>
#' @noRd
n_elements <- function(x)
{
  if(is.recursive(x))
  {
    sum(vapply(x, n_elements, integer(1)))
  } else
  {
    as.integer(prod(DIM(x)))
  }  
}

Try the flippant package in your browser

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

flippant documentation built on Nov. 27, 2023, 5:12 p.m.