The results of my ANOVA are as follows,
mnn=aov(gy~gen+rep, data=my)
summary(mnn)
Df Sum Sq Mean Sq F value Pr(>F)
gen 6 1923.1 320.5 31.206 5.42e-07 ***
rep 1 7.1 7.1 0.695 0.419
Residuals 13 133.5 10.3
Why it is showing only 1 df for rep
instead of 2 when the number of levels of rep are 3 in the data.
Here is my sample dataset,
gen rep gy sy
1 a 1 40 95
2 b 1 50 120
3 c 1 55 120
4 d 1 60 140
5 e 1 40 110
6 f 1 50 125
7 g 1 65 145
8 a 2 35 100
9 b 2 50 125
10 c 2 59 130
11 d 2 65 150
12 e 2 40 110
13 f 2 55 130
14 g 2 60 145
15 a 3 40 100
16 b 3 50 120
17 c 3 50 130
18 d 3 65 145
19 e 3 40 115
20 f 3 55 130
21 g 3 70 155
You presumably intended to treat rep
as a categorical predictor. Because the values of rep
in your data set are numeric (1,2,3), R will assume that rep
is a continuous predictor (and hence you are doing a form of ANCOVA rather than a two-way ANOVA). In this case you have to explicitly specify that the variable is categorical by transforming it with factor()
, either within the data set:
my$rep <- factor(my$rep)
or on the fly during your aov()
call:
aov(gy~gen+factor(rep), data=my)