Defines functions prohibit_unequal_length_vectors

Documented in prohibit_unequal_length_vectors

#' Prohibit unequal length vectors
#' @description Tests whether all vectors have the same length.
#' @param ... Vectors to test.
#' @return An error message unless all of \code{...} have the same length in which case \code{NULL}, invisibly.

prohibit_unequal_length_vectors <- function(...){
  lengths <- vapply(list(...), FUN = length, FUN.VALUE = 0L)
  if (length(unique(lengths)) != 1L){
    stop("Input vectors must all have the same length.")

Try the grattan package in your browser

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

grattan documentation built on May 29, 2018, 1:06 a.m.