title: Linearly regress a vector against each column of a matrix
body: <p>I have a very simple question which I am sure there is an elegant answer to (I am also sure the title above is inappropriate). I have a vector of y values:</p>
  
  <pre><code>y = matrix(c(1, 2, 3, 4, 5, 6, 7), nrow=7, ncol=1)
  </code></pre>
  
  <p>which I would like to regress against each column in a matrix, x:</p>
  
  <pre><code>x = matrix(c(1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 4, 4, 4, 4, 4, 4, 4), nrow=7, ncol=3)
  </code></pre>
  
  <p>For example I would like to linearly regress the first column of x against y and then the second column of x against y until the last column of x is reached:</p>
  
  <pre><code>regression.1=lm(y~x[,1])
  regression.2=lm(y~x[,2])
  </code></pre>
  
  <p>I would later like to plot the slope of these regression versus other parameters so it would be useful if the model coefficient parameters are easily accessible in the usual way:</p>
  
  <pre><code>slope.1 = summary(regression.1)$coefficients[2,1]
  </code></pre>
  
  <p>I am guessing a list using something like plyr but I am too new to this game to find the simplest way to code this.</p>