title: Finding R^2 for each row and rows previous
body: <p>I have an X-Y table and wish to find the R^2 value for all of the rows, then subtract a row and perform the function again.
  I have started with this function:</p>
  
  <pre><code>df&lt;-data.frame(x=1:10,y=1:10)
  
  R2&lt;-function(df)
    for(i in length(df$x)){
    Rsq&lt;-lm(x ~ y, data=df)
    print(Rsq)
  }
  </code></pre>
  
  <p>So this gives me the R^2 for the whole data frame, I just can't seem to work out how to perform the function successively by subtracting a row each time. </p>