Skip to content
Prev 360177 / 398503 Next

Trying to understand cut

Hi John,
Both the "right" and "include.lowest" arguments are usually useful
when there are values equal to those in "breaks". A value equal to a
break can fall on either side of the break depending upon these
arguments:
(0,10]  (10,20]  (20,30]  (30,40]  (40,50]  (50,60]  (60,70]  (70,80]
     10       10       10       10       10       10       10       10
(80,90] (90,100]
     10       10

because the breaks are left-closed all of the values equal to a break
at the higher end are shifted up and the 100 value is lost in this one
[0,10)  [10,20)  [20,30)  [30,40)  [40,50)  [50,60)  [60,70)  [70,80)
      9       10       10       10       10       10       10       10
[80,90) [90,100)
     10       10

but if I include.lowest (which is really highest when right=FALSE),
the highest value in the last cut (100) is preserved.
[0,10)  [10,20)  [20,30)  [30,40)  [40,50)  [50,60)  [60,70)  [70,80)
      9       10       10       10       10       10       10       10
[80,90) [90,100]
     10       11

data.frame(A=nums,
 B=cut(nums,breaks=seq(0,100,by=10),right=FALSE,
 include.lowest=TRUE))

to see the correspondence.

Jim

On Sun, Apr 17, 2016 at 2:12 PM, John Sorkin
<jsorkin at grecc.umaryland.edu> wrote: