title: How to sort vector into bins in R?
body: <p>I have a vector that consists of numbers that can take on any value between 1 and 100.
  I want to sort that vector into bins of a certain size.</p>
  <p>My logic:</p>
  <p>1.) Divide the range (in this case, 1:100) into the amount of bins you want (lets say 10 for this example)</p>
  <p>Result: (1, 10.9], 10.9,20.8],  (20.8,30.7],  (30.7,40.6],  (40.6,50.5],  (50.5,60.4],  (60.4,70.3],  (70.3,80.2],  (80.2,90.1],   (90.1,100]</p>
  <p>2.) Then sort my vector</p>
  <hr />
  <p>I found a handy function that <em>almost</em> does all this in one fell swoop: <code>cut()</code>. Here is my code:</p>
  <pre class="lang-r prettyprint-override"><code>&gt; table(cut(vector, breaks = 10))
  
  (0.959,10.9]  (10.9,20.8]  (20.8,30.7]  (30.7,40.5]  (40.5,50.4]  (50.4,60.3]  (60.3,70.1]    (70.1,80]    (80,89.9]  (89.9,99.8] 
           175          171          117          103           82           67           54           46           39           31 
  
  </code></pre>
  <p>Unfortunately, the intervals are different than the bins we calculated from the possible range (1:100). So I tried fixing this by adding in that range into the vector:</p>
  <pre class="lang-r prettyprint-override"><code>&gt; table(cut(c(1,100,vector), breaks = 10))
  
  (0.901,10.9]  (10.9,20.8]  (20.8,30.7]  (30.7,40.6]  (40.6,50.5]  (50.5,60.4]  (60.4,70.3]  (70.3,80.2]  (80.2,90.1]   (90.1,100] 
           176          171          117          104           82           66           54           48           38           31
  
  </code></pre>
  <p>This almost worked perfectly except the left-most interval which starts from 0.901 for some reason.</p>
  <hr />
  <p>My questions:</p>
  <p>1.) Is there a way to do this (using cut or another function/package) without having to insert artificial data points to get the specified bin ranges?</p>
  <p>2.) If not, why does the lower bin start from 0.901 and not 1?</p>