R/findNN.R

Defines functions findNN

Documented in findNN

#R
# $HeadURL: http://fgcz-svn.unizh.ch/repos/fgcz/testing/proteomics/R/protViz/R/findNN.R $
# $Id: findNN.R 6178 2014-02-27 09:33:30Z cpanse $
# $Date: 2014-02-27 10:33:30 +0100 (Thu, 27 Feb 2014) $


# TODO 
# compute score by sum of error div. by number of hits

findNN<-function(q, vec, check=FALSE) {

    if (check){ if ( is.unsorted(vec)){
        return (list(error="vec is not sorted"))
    }}
  
    out <- .C("__findNN",
        m=as.integer(length(q)),
        n=as.integer(length(vec)),
        q=as.double(q),
        vec=as.double(vec),
        NN=as.integer(rep(-1, length(q))),
        PACKAGE = "protViz")

    return (out$NN + 1)
    
}

Try the protViz package in your browser

Any scripts or data that you put into this service are public.

protViz documentation built on Feb. 16, 2023, 9:45 p.m.