title: cut several variables, using several different number of bins for each variable
body: <p>I have a dataset which looks like this:</p>
  
  <pre><code>ID  a   b
  ID1 0.1 20.3
  ID2 0.2 21.6
  ID3 1.2 1.5
  etc.
  </code></pre>
  
  <p>I would like to group these values into equal-sized groups. This can be done with:</p>
  
  <pre><code>data$bin1 &lt;- as.numeric(cut2(data$b,g=50))
  </code></pre>
  
  <p>This takes the values in column b and divides them into 50 equal-sized groups:</p>
  
  <pre><code>ID  a   b    bin
  ID1 0.1 20.3 2
  ID2 0.2 21.6 2
  ID3 1.2 1.5  1
  etc.
  </code></pre>
  
  <p>However, I need to do this multiple times, with different amount of groups. I tried:</p>
  
  <pre><code>for (i in 1:5){
  data$bin[i] &lt;- as.numeric(cut2(data$values,g=i*50))
  }
  </code></pre>
  
  <p>But then I get this warning: "number of items to replace is not a multiple of replacement length". </p>
  
  <p>After grouping the values, I want to calculate the means within each group, which can be done with:</p>
  
  <pre><code>means &lt;- ddply(data,.(bin),summarise,mean.a=mean(a),mean.b=mean(b))
  </code></pre>
  
  <p>I would like to do this for all the bin sizes. Do I need to use another for loop? Or can it be implemented in the first loop?</p>