R/prohibit_length0_vectors.R

Defines functions prohibit_length0_vectors

Documented in prohibit_length0_vectors

#' Prohibit zero lengths
#' 
#' Tests whether any vectors have zero length.
#' 
#' @param ... A list of vectors
#' @return An error message if any of the vectors \code{...} have zero length.

prohibit_length0_vectors <- function(...){
  lengths <- vapply(list(...), FUN = length, FUN.VALUE = 0L)
  if (any(lengths == 0L)){
    stop("You have passed a zero length vector to this function, which is not allowed.")
  }
}

Try the grattan package in your browser

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

grattan documentation built on Oct. 17, 2018, 1:05 a.m.