Skip to content

Commit

Permalink
Update mclosest.R
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed Sep 29, 2023
1 parent 5f90cdc commit 497ca42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/mclosest.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ mclosest <- function(x,
## Initialize a vector to store closest row indices
closest_indices <- rep(NA_integer_ , nrow(x))
for (i in seq_len(nrow(x))) {
abdiff <- abs(table - rep(x[i, ], each = nrt))
abdiff <- abs(table - rep(x[i, ], each = nr))
## Remove differences lower than tolerance
abdiff[abdiff > rep((tolerance + ppm(x[i,], ppm)), each = nrt)] <- NA
abdiff[abdiff > rep((tolerance + ppm(x[i,], ppm)), each = nr)] <- NA
ranked <- apply(abdiff, 2, rank, na.last="keep")
rowProd <- apply(ranked, 1, prod)
res <- which.min(rowProd)
Expand Down

0 comments on commit 497ca42

Please sign in to comment.