[Rd] Which version of findInterval is used?

From: Peng Yu <pengyu.ut_at_gmail.com>
Date: Thu, 10 Dec 2009 14:35:52 -0600


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)

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 10 Dec 2009 - 20:45:35 GMT

This archive was generated by hypermail 2.2.0 : Thu 10 Dec 2009 - 21:11:04 GMT