R/argmin.R

Defines functions argmin

Documented in argmin

#'  argmin Argmin function for a vector.
#'
#'  Return the index minimizing distance from v to target.
#'  @param v The vector to compare to target.
#'  @param target The value sought in the vector; default=0.
#'  @return  The index in v of the value which is closest to target.

argmin = function(v, target=0)
  sapply(target, function(target)which(abs(v-target) == min(abs(v-target))[1]))

Try the NNTbiomarker package in your browser

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

NNTbiomarker documentation built on May 1, 2019, 11:15 p.m.