title: how to run lm regression for every column in R
body: <p>I have data frame as:</p>
  
  <pre><code>df=data.frame(x=rnorm(100),y1=rnorm(100),y2=rnorm(100),y3=...)
  </code></pre>
  
  <p>I want to run a loop which regresses each column starting from the second column on the first column:</p>
  
  <pre><code>for(i in names(df[,-1])){
      model = lm(i~x, data=df)
  }
  </code></pre>
  
  <p>But I failed. The point is that I want to do a loop of regression for each column and some column names is just a number (e.g. 404.1). I cannot find a way to run a loop for each column using the above command.</p>