Search code examples
rcrananova

How to make simple ANOVA in R


I have to make ANOVA in R using build-in packages, my data seems like this :

dane=cbind(a=rnorm(10),b=rnorm(10),c=c(1,1,1,1,2,2,2,2,2,2))

a and b are variables for which I want to test hypothesis about equality of means in groups assigned by c variable. My case is the simplest case when t-test is not enough.


Solution

  • dane <- data.frame(dane)
    with(dane, aov(c(a[c==1],b[c==2]) ~ c))
    

    Or, if you mean to test both a and b as separate dvs:

    with(dane, aov(a ~ c))
    with(dane, aov(b ~ c))