R/hai-range-statistic.R

Defines functions hai_range_statistic

Documented in hai_range_statistic

#' Get the range statistic
#'
#' @author Steven P. Sandeson II, MPH
#'
#' @description Takes in a numeric vector and returns back the range of that
#' vector
#'
#' @details Takes in a numeric vector and returns the range of that vector using
#' the `diff` and `range` functions.
#'
#' @param .x A numeric vector
#'
#' @examples
#' hai_range_statistic(seq(1:10))
#'
#' @return
#' A single number, the range statistic
#'
#' @export
#'

hai_range_statistic <- function(.x) {

  # Tidyeval ----
  x_term <- .x

  if (!is.numeric(x_term)) {
    stop(call. = FALSE, ".x must be a numeric vector.")
  }

  range_statistic <- base::diff(base::range(x_term))

  return(range_statistic)
}

Try the healthyR.ai package in your browser

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

healthyR.ai documentation built on April 3, 2023, 5:24 p.m.