title: Upper interval limits in function 'cut'
body: <p>I’d like to class a data frame in a certain way in <code>R</code>.<br>
  Assume to have a data frame like the following:</p>
  
  <pre><code>&gt; data = sample(1:500, 5000, replace = TRUE)
  </code></pre>
  
  <p>In order to class this data frame I’m making these classes:</p>
  
  <pre><code>&gt; data.cl = cut(data, breaks = c(seq(0,100,by=10), 200, 350, 480, 500))
  &gt; table(data.cl)
  data.cl
     (0,10]   (10,20]   (20,30]   (30,40]   (40,50] 
        102        80        87       113       117 
    (50,60]   (60,70]   (70,80]   (80,90]  (90,100] 
        101        89        95       106       104 
  (100,200] (200,350] (350,480] (480,500] 
       1002      1492      1318       194 
  </code></pre>
  
  <p>If I want <code>0</code> to be included I’d just have to add <code>include.lowest = TRUE</code>:</p>
  
  <pre><code>&gt; data.cl = cut(data, breaks = c(seq(0,100,by=10), 200, 350, 480, 500),
  + include.lowest = TRUE)
      &gt; table(data.cl)
  data.cl
     [0,10]   (10,20]   (20,30]   (30,40]   (40,50] 
        102        80        87       113       117 
    (50,60]   (60,70]   (70,80]   (80,90]  (90,100] 
        101        89        95       106       104 
  (100,200] (200,350] (350,480] (480,500] 
       1002      1492      1318       194 
  </code></pre>
  
  <p>In this example this doesn’t show any difference, because <code>0</code> isn’t occuring in this data frame at all. But if it would, e.g. <code>4</code> times, there would be <code>106</code> instead of <code>102</code> elements in class <code>[0,10]</code>:</p>
  
  <pre><code>&gt; data.cl = cut(data, breaks = c(seq(0,100,by=10), 200, 350, 480, 500),
  + include.lowest = TRUE)
      &gt; table(data.cl)
  data.cl
     [0,10]   (10,20]   (20,30]   (30,40]   (40,50] 
        106        80        87       113       117 
    (50,60]   (60,70]   (70,80]   (80,90]  (90,100] 
        101        89        95       106       104 
  (100,200] (200,350] (350,480] (480,500] 
       1002      1492      1318       194 
  </code></pre>
  
  <p>There is another option in changing class limits. The default option for <code>cut()</code> is <code>right = FALSE</code>. If you change it to <code>right = TRUE</code> you’ll get:</p>
  
  <pre><code>&gt; data.cl = cut(data, breaks = c(seq(0,100,by=10), 200, 350, 480, 500),
  + include.lowest = TRUE, right = FALSE)
  &gt; table(data.cl)
  data.cl
     [0,10)   [10,20)   [20,30)   [30,40)   [40,50) 
         92        81        87       111       118 
    [50,60)   [60,70)   [70,80)   [80,90)  [90,100) 
        103        89        94       103       103 
  [100,200) [200,350) [350,480) [480,500] 
       1003      1497      1320       199 
  </code></pre>
  
  <p><code>include.lowest</code> now becomes “<code>include.highest</code>” at the price of changing class limits and thus returning different amounts of class members in some classes, because of a slight shift in class limits.<br>
  But if I want to have the data frame</p>
  
  <pre><code>&gt; data.cl = cut(data, breaks = c(seq(0,100,by=10), 200, 350, 480, 500))
  &gt; table(data.cl)
  data.cl
     (0,10]   (10,20]   (20,30]   (30,40]   (40,50] 
        102        80        87       113       117 
    (50,60]   (60,70]   (70,80]   (80,90]  (90,100] 
        101        89        95       106       104 
  (100,200] (200,350] (350,480] (480,500) 
       1002      1492      1318       194
  </code></pre>
  
  <p>to <strong>exclude</strong> <code>500</code>, too, what shall I do?<br>
  Of course, one can say: “Just write <code>data.cl = cut(data, breaks = c(seq(0,100,by=10), 200, 350, 480, 499))</code> instead of <code>data.cl = cut(data, breaks = c(seq(0,100,by=10), 200, 350, 480, 500))</code>, because you’re dealing with integer numbers.”<br>
  Well, that’s right, but what would be if this wouldn’t be the case and I’d use floats instead? How can I exclude <code>500</code> then?</p>