[R] findInterval() surprising behavior
Dmitriy Chernykh
dmit-cher at mail.ru
Mon Oct 17 21:03:25 CEST 2016
Hello,
I call function findInterval in the following way:
findInterval(x=c(6, 1, 1, 1), vec=c(0, 1, 3, 5, 10), left.open=TRUE),
and expect that it will return 4 1 1 1. But the function returns 4 2 1 1 instead. Moreover, if I change the first element in x to, say, 4 -
findInterval(x=c(4, 1, 1, 1), vec=c(0, 1, 3, 5, 10), left.open=TRUE)
then the function returns 3 1 1 1.
Why are results for identical elements in x not the same? And why is element in x influenced by previous one? I suspect this is a bug but I am not 100% sure.
Technical details:
sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS
locale:
[1] LC_CTYPE=ru_RU.UTF-8 LC_NUMERIC=C LC_TIME=ru_RU.UTF-8 LC_COLLATE=ru_RU.UTF-8 LC_MONETARY=ru_RU.UTF-8
[6] LC_MESSAGES=ru_RU.UTF-8 LC_PAPER=ru_RU.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.3.1
Thanks.
--
Dmitrii Chernykh
[[alternative HTML version deleted]]
More information about the R-help
mailing list