Dear R People:
thanks SO MUCH for the quick responses to the breaks questions.
Here are two possible solutions:
I think what you're looking for is ?cut:
R> xx = c(-2.0, 1.4, -1.2, -2.2, 0.4, 1.5, -2.2, 0.2, -0.4, -0.9)
andR> cut(xx, breaks = c(-Inf, -2.2, -0.97, 0.27, 1.5, Inf))
[1] (-2.2,-0.97] (0.27,1.5] (-2.2,-0.97] (-Inf,-2.2] (0.27,1.5]
[6] (0.27,1.5] (-Inf,-2.2] (-0.97,0.27] (-0.97,0.27] (-0.97,0.27]
Levels: (-Inf,-2.2] (-2.2,-0.97] (-0.97,0.27] (0.27,1.5] (1.5,Inf]
R>
Status: R
t1 <- outer(data, breaks + c(rep(0, length(breaks)-1), 1e-5), "<")
Apply(t1, 1, function(x){min(which(x))}) - 1
Adding to the final break point makes sure that every data point will be
less than some break point.
So: