[R] aov and groups coding

Massimo Bressan mbressan at arpa.veneto.it
Wed Oct 1 13:00:34 CEST 2014


please consider the following example:

#start code

set.seed(123)
level<-rnorm(18, 10,3)

group1<-rep(letters[1:3], each=6)
summary(aov(level~group1))

group2<-rep(1:3,each=6)
str(group2)
summary(aov(level~group2))

#same result as for group1
summary(aov(level~factor(group2)))

#same result ad for aov
anova(lm(level~group2))

#end code

what I would like to do is to perform an anova among groups (analysis of 
variance for three different gruops);
consider that groups are completely arbitrary: they are not intended to 
have any sort of scaling or ordinal meaning;

in my example same groups are coded in two alternative ways: group1 as 
"chr" (factor) and group2 as "num"; so by keeping in mind my purpose (is 
there any difference in the level among groups?) I would simply consider 
the result of aov()  for group2 (num) as a non sense (with respect to my 
specific purpuse)
is that a correct interpretation?
I hope not having misinterpreted the indications of the following thread
http://r.789695.n4.nabble.com/Question-about-factor-that-is-numeric-in-aov-td2164393.html


thank you for any help

best regards

max



More information about the R-help mailing list