From pengyu.ut at gmail.com  Thu Dec 10 21:35:52 2009
From: pengyu.ut at gmail.com (Peng Yu)
Date: Thu, 10 Dec 2009 14:35:52 -0600
Subject: [Rd] Which version of findInterval is used?
Message-ID: <366c6f340912101235m6d7e2773q173abd5594ceca7a@mail.gmail.com>

In an R session, I see the following, which means that findInterval is
an R function.

> findInterval
function (x, vec, rightmost.closed = FALSE, all.inside = FALSE)
{
    if (any(is.na(vec)))
        stop("'vec' contains NAs")
    if (is.unsorted(vec))
        stop("'vec' must be sorted non-decreasingly")
    if (has.na <- any(ix <- is.na(x)))
        x <- x[!ix]
    nx <- length(x)
    index <- integer(nx)
    .C("find_interv_vec", xt = as.double(vec), n = length(vec),
        x = as.double(x), nx = nx, as.logical(rightmost.closed),
        as.logical(all.inside), index, DUP = FALSE, NAOK = TRUE,
        PACKAGE = "base")
    if (has.na) {
        ii <- as.integer(ix)
        ii[ix] <- NA
        ii[!ix] <- index
        ii
    }
    else index
}
<environment: namespace:base>


However, I also see a C function with the same name in
src/appl/interv.c. I'm wondering where is this use?

int findInterval(double *xt, int n, double x,
		  Rboolean rightmost_closed,  Rboolean all_inside, int ilo,
		  int *mflag)



[Rd] Which version of findInterval is used?
Peng Yu