title: How to calculate slope and intercept for every row in different columns
body: <p>I am trying to calculate the slope and intercept for every row in different columns in a dataframe. The output (intercept and slope) should be added to the original data frame as new columns.</p>
  <p>To be as clear as possible of what I am trying to achieve, I have provided some of my data below:</p>
  <pre><code>locations&lt;-c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;)
  
  proportion.I&lt;-c(0.073846154, 0.079710145, 0.063218391)
  
  proportion.II&lt;-c(0.049773659, 0.033756955, 0.011237956)
  
  proportion.III&lt;-c(0.090322581, 0.100917431, 0.08051443)
  
  abundance.I&lt;-c(331,331,331)
  
  abundance.II&lt;-c(178,178,178)
  
  abundance.III&lt;-c(87,87,87)
  
  output.slope&lt;-c(5.539e-05, -4.665e-05, -2.819e-05)
  
  output.intercept&lt;-c(5.128e-02, 8.073e-02, 5.726e-02)
  
  df&lt;-data.frame(locations, proportion.I, proportion.II, proportion.III, abundance.I, abundance.II, abundance.III, output.slope, output.intercept)
  </code></pre>
  <p>*The 'dependent' variables for my linear regression will be 'Proportion' (rows 2:4) and the predictor (or independent) variables will be 'abundance' (rows 5:7).</p>