R/nearestV.R

Defines functions nearestV

Documented in nearestV

#' Nearest Value
#'
#' Function to find the nearest value from within a set of values
#'
#' @param value The value to be matched
#' @param values The set of values with which the value is being compared
#'
#' @return The nearest value
#'
#' @examples
#' a <- runif()
#' nearestV(50, a)
#'
#' @export 

nearestV = function(value, values) {

  outN = which.min( abs(values-value) )
  outV = values[outN]
  return(outV)
}
mathesong/granviller documentation built on April 20, 2020, 7:28 p.m.