"-"))== mm, arr.ind=TRUE)[2]]
Cheers
Petr
> -Original Message-
> From: R-help On Behalf Of Dario Strbenac
> Sent: Tuesday, August 18, 2020 9:00 AM
> To: r-help@r-project.org
> Subject: [R] Calculating Minimum Absolute Difference of Two Numeric
Vectors
>
> Good da
This looks more like a code challenge than a real problem, but anyway Rcpp
seems unnecessary.
x <- (2:5)^2/3
y <- (1:6)+0.1
ad <- function( a, b ) {
abs( a - b )
}
M <- outer( x, y, FUN=ad )
which( M==min(M), arr.ind = TRUE )
On August 18, 2020 12:00:09 AM PDT, Dario Strbenac
wrote:
>Good da
Good day,
What is a fast and efficient way to calculate the minimum absolute difference
between two vectors of numbers? The two vectors have unequal length. I would
also like to know the index of the first vector and the second vector which
results in the minimum absolute difference. For exampl
3 matches
Mail list logo