get_nearest_row: Search for closest row in a truth matrix for each row in a...

View source: R/modules-sc-utils.R

get_nearest_rowR Documentation

Search for closest row in a truth matrix for each row in a test matrix.

Description

from Stack Overflow: 40668623

Usage

get_nearest_row(truth, test)

Arguments

truth

matrix to pick nearest from for all rows in test.

test

matrix to test each row of and find closest rows in truth.

Value

vector of rows in truth that are the nearest to each row in test.

Examples

set.seed(123)  ## for reproducibility
D <- 2 #amount of dimensions
K <- 5
events <- 2*K #number of events
truth <- matrix(data=runif(events, min = 0, max = 1), nrow=K)
E <- 2
test <- matrix(data=runif(2*E, min = 0, max = 1), nrow=E)

## Not run: 
#[1] 4 3
get_nearest_row(truth, test)

## End(Not run)


hms-dbmi/drugseqr documentation built on Feb. 15, 2024, 10:38 p.m.