findInterval函数中的异常

时间:2014-09-06 18:47:01

标签: r

我想使用findInterval函数,但它对边框上的数字起作用。这是我观察到的异常现象。

bins <- seq(from = -4.4, to = 1.2, by = .8); bins
[1] -4.4 -3.6 -2.8 -2.0 -1.2 -0.4  0.4  1.2
findInterval(x = -.4, vec = bins)
[1] 6
findInterval(x = .4, vec = bins)
[1] 6

bins <- seq(from = -3.6, to = 1.2, by = .8); bins
[1] -3.6 -2.8 -2.0 -1.2 -0.4  0.4  1.2
findInterval(x = -.4, vec = bins)
[1] 4
findInterval(x = .4, vec = bins)
[1] 6

bins <- seq(from = -2.8, to = 1.2, by = .8); bins
[1] -2.8 -2.0 -1.2 -0.4  0.4  1.2
findInterval(x = -.4, vec = bins)
[1] 3
findInterval(x = .4, vec = bins)
[1] 4

我期待输出像最后一个。 我在这里错过了什么吗?为什么这个函数以连续的方式放置连续的数字?

0 个答案:

没有答案