Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


DDHFm (version 1.0-2.1)

which.min.diff: Find index where two vectors are closest

Description

Finds the index point where two index vectors are closest in value

Usage

which.min.diff(a, vect)

Arguments

a
input vector
vect
input vector

Value

  • The index where abs(a-vect) is smallest, ie where a and vect are smallest.

Examples

Run this code
#
# Make up two vectors
#
a <- c(1,2,3)
vect <- c(3,2,1)
#
# Now see on which index are the two closest in value 
#
which.min.diff(a,vect)
#[1] 2
#
# ie its the second index where both vectors are actually 2

Run the code above in your browser using DataLab