Skip to content

Commit

Permalink
added definition of function
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed Sep 18, 2023
1 parent f0ff641 commit 16c687f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export(isRkmd)
export(isotopicSubstitutionMatrix)
export(isotopologues)
export(mass2mz)
export(mclosest)
export(multiplyElements)
export(mz2mass)
export(pasteElements)
Expand Down
23 changes: 14 additions & 9 deletions R/mclosest.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@


@title
#'@title Extract closest values in a pairwise manner between two matrices
#'
#' @description
#' @description
#'
#' `mclosest` ...
#' `mclosest` functions calculate the closest rows in a pairwise manner.
#' It returns the index of the closest row in 'table' for each row in 'x'
#'
#' @param
#' @param x `numeric` matrix or data frame representing the query data.
#'
#' @param
#' @param table `numeric` matrix or data frame containing the reference data.
#'
#' @param ppm `numeric` value specifying the parts per million tolerance for
#' considering values as equal (default is 0).
#'
#' @param tolerance ...
#'
#' @return
#' @return `numeric` vector of indices indicating the closest row of 'table' for each row of 'x'
#'
#' @author Philippine Louail
#'
Expand All @@ -20,7 +24,8 @@
#' x <- data.frame(a = 1:5, b = 3:7)
#' table <- data.frame(c = c(11, 23, 3, 5, 1), d = c(32:35, 45))
#' ppm <- 0.5
#' mclosest(x, table, ppm = 0.5)
#'



mclosest <- function(x,
Expand Down
13 changes: 12 additions & 1 deletion tests/testthat/test_mclosest.R
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
#' Test file for mclosest function
test_that("mclosest works", {
## load test data
x <- data.frame(a = 1:5, b = 3:7)
table <- data.frame(c = c(11, 23, 3, 5, 1), d = c(32:35, 45))
ppm <- 0.5
mclosest(x, table, ppm = 0.5)
})

#one block or multiple ?
#testing format: expect warning and ppm multiplication
#test that: one row work -> gives info if the basic flow works
#test that loop works ?

0 comments on commit 16c687f

Please sign in to comment.