breaks
Martin Maechler <maechler at stat.math.ethz.ch> wrote:
findInterval()
Hi, Martin. I wasn't aware of findInterval(). findInterval(x, vec) looks to me very similar to: R> cut(x, c(-Inf,vec,Inf), labels=FALSE, right=FALSE) - 1 so I'm curious what the differences are (e.g. speed, duplicates in vec?). In any case, findInterval() and cut() ought to be in each other's "See Also", don't you think? R> xx <- c(-2.0, 1.4, -1.2, -2.2, 0.4, 1.5, -2.2, 0.2, -0.4, -0.9) R> xx.y <- c(-2.2000000, -0.9666667, 0.2666667, 1.5000000) R> findInterval(xx, xx.y) [1] 1 3 1 1 3 4 1 2 2 2 R> cut(xx, c(-Inf,xx.y,Inf), labels=FALSE, right=FALSE) - 1 [1] 1 3 1 1 3 4 1 2 2 2
-- David Brahm (brahm at alum.mit.edu)