# What's wrong with my code for ANOVA test in R? [closed]

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.

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

You need to specify that fertilizer is a factor variable. Use the code:
data.aov <- aiv(yield ~ factor(fertilizer), data = data)