title: Using ntile to split into groups of 2 or 3
body: <p>I'd like to use <code>ntile</code> from package <code>dplyr</code> to generate a vector of quantiles. The problem occurs when I have a low number of groups to divide my data into.</p>
  
  <p>For example, if I have a vector of <code>-1</code> and <code>1</code>, the value <code>-1</code> should be in quantile 1 and value <code>1</code> should be in quantile 2:</p>
  
  <pre><code>library(dplyr)
  index2 &lt;- rep(c(-1,1,-1),each=4) 
  #[1] -1 -1 -1 -1  1  1  1  1 -1 -1 -1 -1
  </code></pre>
  
  <p>However, using <code>ntile</code>, the last two data points are in the wrong quantile (2 instead of 1)</p>
  
  <pre><code>ntile(index2,2)
  # [1] 1 1 1 1 2 2 2 2 1 1 2 2
  </code></pre>
  
  <p>Here's the result I would expect for the index2 quantiles:</p>
  
  <pre><code>   #  1  1  1  1  2  2  2  2  1  1  1  1
  </code></pre>
  
  <p>I have the same problem with <code>n=3</code>. The results are not as expected.</p>
  
  <pre><code>index3 &lt;- rep(c(-1,1,-2,-2),each=3)
  #[1] -1 -1 -1  1  1  1 -2 -2 -2 -2 -2 -2
  ntile(index3,3)
  #[1] 2 2 3 3 3 3 1 1 1 1 2 2
  </code></pre>
  
  <p>Here's the result I would expect for the index3 quantiles:</p>
  
  <pre><code>#  2  2  2  3  3  3  1  1  1  1  1  1
  </code></pre>
  
  <p>I'm also open to a <code>cut</code> and <code>quantile()</code> solution.</p>