title: "Growing" data frame by replicating rows
body: <p>I am trying to calibrate a model and I need to vary some parameters to see how the output behaves. To do that I would like to create a data frame where each row is one set of parameters.<br>
  An example data set:  </p>
  
  <pre><code>pars &lt;- data.frame(a=3, b=4, c=5)
  </code></pre>
  
  <p>Vary the parameter <code>a</code>:  </p>
  
  <pre><code>dfa &lt;- data.frame(a = 1:6)
  </code></pre>
  
  <p>Then try to join it in a new data frame:  </p>
  
  <pre><code>bind_cols(dfa, pars[rep(seq_len(nrow(pars)), each=length(a)),])  
  </code></pre>
  
  <p>The same process goes for <code>b</code>.</p>
  
  <pre><code>dfb &lt;- data.frame(b = 3:6)
  
  dfb &lt;- 
    bind_cols(dfb, pars[rep(seq_len(nrow(pars)), each=length(dfb$b)),]) %&gt;% 
    select(-c(b1))
  
  bind_rows(dfa,dfb)
  </code></pre>
  
  <p>This is not a very effective way for a model of around 30 parameters. 
  I am guessing this should be put into a loop of some sort. I am probably not the first person trying to do this, so I would appreciate some help if someone has already done this. Some answers to similar problems are <a href="https://stackoverflow.com/questions/8753531/repeat-data-frame-n-times">this</a> and I have used <a href="https://stackoverflow.com/questions/11121385/repeat-rows-of-a-data-frame/11121463">this</a> as a part of my attempt. This comment is also interesting because I have a varying number of rows to repeat:   </p>
  
  <pre><code>n.times &lt;- c(2,4) ; df[rep(seq_len(nrow(df)), n.times),] 
  </code></pre>
  
  <p>Any help on this is appreciated. </p>