title: Fitting linear model / ANOVA by group
body: <p>I'm trying to run <code>anova()</code> in R and running into some difficulty. This is what I've done up to now to help shed some light on my question. </p>
  
  <p>Here is the <code>str()</code> of my data to this point.</p>
  
  <pre><code> str(mhw)
  'data.frame':   500 obs. of  5 variables:
  $ r    : int  1 2 3 4 5 6 7 8 9 10 ...
  $ c    : int  1 1 1 1 1 1 1 1 1 1 ...
  $ grain: num  3.63 4.07 4.51 3.9 3.63 3.16 3.18 3.42 3.97 3.4 ...
  $ straw: num  6.37 6.24 7.05 6.91 5.93 5.59 5.32 5.52 6.03 5.66 ...
  $ Quad : Factor w/ 4 levels "NE","NW","SE",..: 2 2 2 2 2 2 2 2 2 2 ...
  </code></pre>
  
  <p>Column r is a numerical value indicating which row in the field an individual plot resides
  Column c is a numerical value indicating which column an individual plot resides<br>
  Column Quad corresponds to the geographical location in the field to which each plot resides</p>
  
  <pre><code>Quad &lt;- ifelse(mhw$c &gt; 13 &amp; mhw$r &lt; 11, "NE",ifelse(mhw$c &lt; 13 &amp; mhw$r &lt; 11,"NW", ifelse(mhw$c &lt; 13 &amp; mhw$r &gt;= 11, "SW","SE")))
  mhw &lt;- cbind(mhw, Quad)
  </code></pre>
  
  <p>I have fit a <code>lm()</code> as follows</p>
  
  <pre><code>nov.model &lt;-lm(mhw$grain ~ mhw$straw)
  anova(nov.model)
  </code></pre>
  
  <p>This is an <code>anova()</code> for the entire field, which is testing grain yield against straw yield for each plot in the dataset.</p>
  
  <p>My trouble is that I want to run an individual <code>anova()</code> for the Quad column of my data to test grain yield and straw yield in each quadrant.</p>
  
  <p>perhaps a <code>with()</code> might fix that. I have never used it before and I am in the process of learning R currently. Any help would be greatly appreciated.</p>