[R] Multiple ANOVA tests
Mike Lawrence
Mike.Lawrence at dal.ca
Wed May 27 13:10:36 CEST 2009
#create some data
y=rnorm(20)
x=factor(rep(c('A','B'),each=10))
#run the anova
my_aov = aov(y~x)
#summarize the anova
my_aov_summary = summary(my_aov)
#show the anova summary
print(my_aov_summary)
#lets see what's in the summary object
str(my_aov_summary)
#looks like it's a list with 1 element which
#in turn is a data frame with columns.
#The "Pr(>F)" column looks like what we want
my_aov_summary[[1]]$P
#yup, that's it. Grab the first value
p = my_aov_summary[[1]]$P[1]
On Wed, May 27, 2009 at 7:11 AM, Imri <bisrael at agri.huji.ac.il> wrote:
>
> Hi all -
> I'm trying to do multiple one-way ANOVA tests of different factors on the
> same variable. As a result I have a list with all the ANOVA tables, for
> exemple:
>
> $X11_20502
> Analysis of Variance Table
>
> Response: MPH
> Df Sum Sq Mean Sq F value Pr(>F)
> x 3 369.9 123.3 6.475 0.0002547 ***
> Residuals 635 12093.2 19.0
> ---
> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> $X11_21067
> Analysis of Variance Table
>
> Response: MPH
> Df Sum Sq Mean Sq F value Pr(>F)
> x 1 26.7 26.7 1.3662 0.2429
> Residuals 637 12436.4 19.5
>
> $X11_10419
> Analysis of Variance Table
>
> Response: MPH
> Df Sum Sq Mean Sq F value Pr(>F)
> x 3 527.8 175.9 9.361 4.621e-06 ***
> Residuals 635 11935.3 18.8
> ---
> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> My question is how can I extract from this list, just the Pr(>F) values for
> each x ?
> --
> View this message in context: http://www.nabble.com/Multiple-ANOVA-tests-tp23739615p23739615.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar
~ Certainty is folly... I think. ~
More information about the R-help
mailing list