R/closest.R

Defines functions closest

Documented in closest

#' A function to get the closest value from a vector
#' @export

closest <- function(x, y)
{
    xy <- abs(x - y)
    closest <- which(xy == min(xy))
    names(closest) <- names(y)

    return(closest)
}
prestevez/crimeineq documentation built on May 29, 2019, 7:39 a.m.