[Rd] findInterval(all.inside=TRUE) for degenerate 'vec' arguments
Martin Maechler
maechler at stat.math.ethz.ch
Fri Aug 5 17:53:25 CEST 2016
>>>>> William Dunlap via R-devel <r-devel at r-project.org>
>>>>> on Thu, 4 Aug 2016 15:20:57 -0700 writes:
> What should findInterval(x,vec,all.inside=TRUE) return when length(vec)<=1,
> so there are no inside intervals?
> R-3.3.0 gives a decreasing map of x->output when length(vec)==1 and -1's
> when length(vec)==0. Would '0' in all those cases be better?
Yes. '0' would be according to the documentation,
and if you dig all the way down to the C part
(originally created via f2c (!)),
you'll notice that the -1
are really from 'n - 1' where n == 0 here ... a case that was
not even possible in the very original (Fortran!) code.
I'll commit a fix to the source
Martin
--
Martin Maechler
ETH Zurich / R Core Team
>> findInterval(x=c(10, 11, 12), vec=11, all.inside=TRUE,
> rightmost.closed=FALSE, left.open=FALSE)
> [1] 1 0 0
>> findInterval(x=c(10, 11, 12), vec=11, all.inside=TRUE,
> rightmost.closed=FALSE, left.open=TRUE)
> [1] 1 1 0
>> findInterval(x=c(10, 11, 12), vec=11, all.inside=TRUE,
> rightmost.closed=TRUE, left.open=FALSE)
> [1] 1 0 0
>> findInterval(x=c(10, 11, 12), vec=11, all.inside=TRUE,
> rightmost.closed=TRUE, left.open=TRUE)
> [1] 1 1 0
>>
>> findInterval(x=c(10, 11, 12), vec=numeric(), all.inside=TRUE,
> rightmost.closed=FALSE, left.open=FALSE)
> [1] -1 -1 -1
>> findInterval(x=c(10, 11, 12), vec=numeric(), all.inside=TRUE,
> rightmost.closed=FALSE, left.open=TRUE)
> [1] -1 -1 -1
>> findInterval(x=c(10, 11, 12), vec=numeric(), all.inside=TRUE,
> rightmost.closed=TRUE, left.open=FALSE)
> [1] -1 -1 -1
>> findInterval(x=c(10, 11, 12), vec=numeric(), all.inside=TRUE,
> rightmost.closed=TRUE, left.open=TRUE)
> [1] -1 -1 -1
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> [[alternative HTML version deleted]]
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list