Skip to content
Prev 360179 / 398503 Next

Trying to understand cut

This isn't really FAQ 7.31 (for once). 

The clue is in this part of cut.default():

            breaks <- seq.int(rx[1L], rx[2L], length.out = nb)
            breaks[c(1L, nb)] <- c(rx[1L] - dx/1000, rx[2L] + 
                dx/1000)

which _is_ as documented. Notice that it is based on the range(values) which in your example is 0-99.9, so the thing boils down to
[1] 99.9
+                 dx/1000)
[1] -0.0999  9.9900 19.9800 29.9700 39.9600 49.9500 59.9400 69.9300 79.9200
[10] 89.9100 99.9999

Notice that all the breakpoints have a nonzero 2nd decimal digit, which none of your data  have, so no data are on interval boundaries and left/right and include.lowest have no effect. There's a little fuzz at the ends to prevent the extremes from being excluded without having to explicitly set include.lowest=TRUE.

Short version: If you want fine control over the cutpoints, do not use cut(x,n)...

-pd

PS: To read the FAQ, go to www.r-project.org, and click "FAQs" (under Documentation, to the left).