title: vector to dataframe in r given length of vector
body: <p>I have vectors of different lengths.  For instance:</p>
  
  <pre><code>df1
  [1]   1  95   5   2 135   4   3 135   4   4 135   4   5 135   4   6 135   4
  
  df2
  [1]   1  70   3   2 110   4   3 112   4
  </code></pre>
  
  <p>I'm trying to write a script in R in order to have any vector enter the function or for loop and it returns a dataframe of three columns.  So a separate dataframe for each input vector.  Each vector is a multiple of three (hence, the three columns).  I'm fairly new to R in terms of writing functions and can't seem to figure this out.  Here was my attempt:</p>
  
  <pre><code>newdf = c()
  ld &lt;- length(df1)
  ld_mult &lt;- length(df1)/3
  ld_seq &lt;- seq(from=1,to=ld,by=3)
  ld_seq2 &lt; ld_seq +2
  for (i in 1:ld_mult) {
    newdf[i,] &lt;- df1[ld_seq[i]:ld_seq2[i]]
  }
  </code></pre>
  
  <p>the output I want for df1 would be:</p>
  
  <pre><code>1 95    5
  2 135   4
  3 135   4
  4 135   4
  5 135   4
  6 135   4
  </code></pre>