[Rd] Which version of findInterval is used?

Peng Yu pengyu.ut at gmail.com
Thu Dec 10 21:35:52 CET 2009


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)



More information about the R-devel mailing list