title: 1 Way Anova Test in R incorrect df
body: <p>I want to run an anova test in R to find out if there's a difference in the number of weeks of each brand. My code is as follows: </p>
  
  <pre><code>weeks = c(100,96,92,96,92,76,80,75,84,82,108,100,96,98,100)
  brand = c('a','a','a','a','a','b','b','b','b','b','c','c','c','c','c')
  battery.exp = data.frame(brand, weeks)
  test.1 = aov(battery.exp$weeks~battery.exp$brand)
  summary(test.1)
  </code></pre>
  
  <p>I'm getting incorrect results in the summary. The df of the brand should be 2, but my output says 3. Does anyone know why I would get incorrect results in my anova test? I've also tried to replace the second to last line with the following: </p>
  
  <pre><code>test.1 = aov(battery.exp$weeks~factor(battery.exp$brand))
  </code></pre>
  
  <p>but that also didn't solve the problem. Any suggestions on how to fix? </p>