R/check_numeric_vector.R

#' Check Numeric Vector
#'
#' This function will take an input and check if it is a single numeric vector.
#' If it isn't then the function will throw an error. If it is then the function
#' doesn't do anything.
#'
#' @param x
#'
#' @return
#' @export
#'
#' @examples
#' x <- 1:10
#' check_numeric_vector
#'
#' y <- 'string'
#' check_numeric_vector(y)  ## Will throw error
check_numeric_vector <- function(x) {

  if (!is.null(dim(x))) {

    stop('Data is not a single numeric vector')

  }

  if (length(x) == 0) {

    stop('Vector is of length 0')

  }

  if (is.numeric(x) == FALSE) {

    stop('Given data is not numeric')

  }


}
AshleyDennisHenderson/data.summary documentation built on June 12, 2019, 11:25 a.m.