title: Vectors of different lengths from a `for` cycle in R: merging in a data frame
body: <p>I have the following elementary issue in R.</p>
  
  <p>I have a <code>for (k in 1:x){...}</code> cycle which produces numerical vectors whose length depends on <code>k</code>.
  For each value of <code>k</code> I produce a single numerical vector.</p>
  
  <p>I would like to collect them as rows of a data frame in R, if possible. In other words, I would like to introduce a data frame <code>data</code> s.t. </p>
  
  <pre><code>    for (k in 1:x) {
              data[k,] &lt;- ...      
                       }
  </code></pre>
  
  <p>where the dots represent the command producing the vector with length depending on <code>k</code>. </p>
  
  <p>Unfortunately, as far as I know, the length of the rows of a dataframe in R is constant, as it is a list of vectors of equal length. I have already tried to complete each row with a suitable number of zeroes to arrive at a constant length (in this case equal to <code>x</code>). I would like to work "dynamically", instead.  </p>
  
  <p>I do not think that this issue is equivalent to merge vectors of different lengths in a dataframe; due to the <code>if</code> cycle, only 1 vector is known at each step.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>A very easy example of what I mean. For each <code>k</code>, I would like to write the vector whose components are <code>1,2,...,k</code> and store it as <code>k</code>th row of the dataframe <code>data</code>. In the above setting, I would write</p>
  
  <pre><code> for (k in 1:x) {
                  data[k,] &lt;- seq(1,k,1)     
                           }
  </code></pre>
  
  <p>As the length of <code>seq(1,k,1)</code> depends on <code>k</code> the code does not work.</p>