R/minimum.R

#' Minimum
#'
#' This function takes a single numeric vector and returns the minimum value in the vector.
#'
#' @param x Numeric vector of values
#'
#' @return Minimum value
#' @export
#'
#' @examples
#' x <- 1:10
#' minimum(x)
minimum <- function(x){

  check_numeric_vector(x)  # Check that the input is a single numeric vector

  n <- length(x)  # Number of elements in x
  x_min <- x[1]

  for (i in 2:n){

    if (x[i] < x_min){

      x_min <- x[i]

    }

  }

  return(x_min)

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