title: Split a vector into chunks
body: <p>I have to split a vector into n chunks of equal size in R. I couldn't find any base function to do that. Also Google didn't get me anywhere. Here is what I came up with so far;</p>
  <pre><code>x &lt;- 1:10
  n &lt;- 3
  chunk &lt;- function(x,n) split(x, factor(sort(rank(x)%%n)))
  chunk(x,n)
  $`0`
  [1] 1 2 3
  
  $`1`
  [1] 4 5 6 7
  
  $`2`
  [1]  8  9 10
  </code></pre>