R/tests-helper-functions.R

Defines functions is_valid_input contains_na

Documented in contains_na is_valid_input

#' Check if input contains any NA values.
#' @param x A vector to check.
contains_na <- function(x) {
  if (any(is.na(x))) return(TRUE)
  return(FALSE)
}

#' Checks if an input vector is valid.
#' @param x A vector to check.
is_valid_input <- function(x) {
  if (is.null(x)) return(FALSE)
  if (contains_na(x)) return(FALSE)
  return(TRUE)
}
kahaaga/tstools documentation built on Nov. 30, 2017, 7:24 a.m.