0
$\begingroup$

Could someone help me see why my code in R does not produce the correct output or do I have a misunderstanding on ANOVA test? As you can see, there are three categories for fertilizer but the degrees-of-freedom shows only one. Shouldn't it be two?

I've attached the dataset link here for those who wish to try it out and a screenshot of my code and its output.

enter image description here

$\endgroup$
4
  • 3
    $\begingroup$ You need to specify that fertilizer is a factor variable. Use the code data.aov <- aiv(yield ~ factor(fertilizer), data = data). $\endgroup$
    – Ben
    Jul 8 at 11:07
  • $\begingroup$ Thanks it works now $\endgroup$
    – AMX
    Jul 8 at 11:11
  • $\begingroup$ Please accept Ben's response as the answer. $\endgroup$
    – JimGrange
    Jul 8 at 11:31
  • 1
    $\begingroup$ @JimGrange: I've converted to answer to allow it to be accepted and closed off. $\endgroup$
    – Ben
    Jul 8 at 11:50

1 Answer 1

2
$\begingroup$

You need to specify that fertilizer is a factor variable. Use the code:

data.aov <- aiv(yield ~ factor(fertilizer), data = data)
$\endgroup$
1
  • 1
    $\begingroup$ @AMX: If you're satisfied with this answer, please accept (the tick button) so that we an close this one off. Thanks, Ben. $\endgroup$
    – Ben
    Jul 8 at 23:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.