title: How to subset a range of values in lm()
body: <p>The help file for lm() doesn't go into the syntax for the subset argument.  I am not sure how to get it to find the line of best fit for only a portion of my data set.  This question is similar, but I wasn't able to solve my particular problem using it.  <a href="https://stackoverflow.com/questions/11328003/how-does-the-subset-argument-work-in-the-lm-function">How does the subset argument work in the lm() function?</a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>    with(dat[dat$SIZE &lt;7 &amp; dat$SIZE &gt; 0.8 ,], plot(SP.RICH~SIZE, log="x",
        xlim=c(1,9), ylim=c(60,180), ylab="plant species richness", 
        xlab="log area (ha)", type="n"))
     with(dat[dat$SIZE &lt;7 &amp; dat$SIZE &gt; 0.8 ,], points(SP.RICH~SIZE, pch=20, cex=1))
     fit=lm(SP.RICH~SIZE, subset=c(1:7))
  </code></pre>
  
  <p>I would like to make sure that the regression line is drawn only for the values that I subset above in the plot() and points() commands.</p>