title: Create columns in R within a for loop
body: <p>I have a data frame in R and I would like to create new columns within a for loop. I have tried many things for the last 2 days but without success.  At the end, I did find a solution that seems to work, but it doesn't seem very straight forward.  I was wondering if anybody has a more elegant way to do this.<br>
  Sorry if this has already been addressed but I couldn't find similar question on SO<br>
  Here is my example.  </p>
  
  <pre><code>x &lt;- runif(20)
  a &lt;- as.data.frame(x)
  for (i in 1:100){
    d &lt;- x + i
    a &lt;- cbind(a, d)
  }
  
  c &lt;- 1
  for (i in 1:100){
    c[i] &lt;- paste0("colum", i)
      }
  colnames(a) &lt;- c("x", c)
  </code></pre>
  
  <p>Thanks in advance for any good suggestions to make this process all within one loop instead of 2.  </p>