Reputation: 743
i have a df with 2 columns:
df <- read.table(text=" a b
1 1 g1
2 7 g1
3 9 g1
4 15 g1
5 17 g1
6 3 g2
7 5 g2
8 9 g2
9 11 g2
10 7 g2", header=TRUE)
so i want to compare g1 vs g2 using the "a" columns, something like
aov(g1 ~ g2, data=df)
well it will be ok with columns, but with rows how can I do it ????
Upvotes: 0
Views: 245
Reputation: 460
The tilde is read "as a function of". Your comparison is: A as a function of B, rather than what you are trying: g1 "compared to" g2. The solution is:
aov(a~b, data = df)
Upvotes: 1