title: How to extract coefficients outputs from a linear regression with loop
body: <p>I would like to know how I can loop a regression n times, and in each time with a different set of variables, extract a <code>data.frame</code> where each column is a regression and each row represent a variable.</p>
  
  <p>In my case I have a <code>data.frame</code> of:</p>
  
  <pre><code>dt_deals &lt;- data.frame(Premium=c(1,3,4,5),Liquidity=c(0.2,0.3,1.5,0.8),Leverage=c(1,3,0.5,0.7))
  </code></pre>
  
  <p>But I have another explanatory dummy variable called <code>hubris</code>, that is the product of a binomial distribution, with 0.25 of mean. Like that:</p>
  
  <pre><code>n &lt;- 10 
  hubris_dataset &lt;- data.frame(replicate(n, rbinom(4,1,0.25))
  </code></pre>
  
  <p>In this sense, what I need is to make n simulation of <code>hubris</code>, so I can, make n regression each one with a different set of random binomial distribution and the output of each distribution needs to be put in a <code>data.frame</code>
  So far I could reach this:</p>
  
  <pre><code># define n as the number of simulations i want
  n=10
  # define beta as a data.frame to put every coefficient from the lm regression
  beta=NULL
  
  for(i in 1:n) {
    dt_deals2 &lt;- dt_deals
    beta[[i]] &lt;- coef(lm(dt_deals$Premium ~ dt_deals$Liquidity + dt_deals$Leverage + hubris_dataset[,i], data=dt_deals2))
    beta &lt;- cbind(reg$coefficients)
  }
  </code></pre>
  
  <p>But this way it only generate the first set of coefficient, and doesn't make another ten columns for the <code>data.frame</code>.</p>