[R] how to get the value of aov summary into another variable

Peter Alspach PAlspach at hortresearch.co.nz
Wed Oct 29 02:00:45 CET 2008


In general, examine the structure of the object and go from there.


will reveal that summary(aov.ex) is a list of 1.  Thus you probably want
to examine that single element in more detail:

str(summary(aov.ex)[[1]])  # the [[1]] to get the first element of the

This is a data.frame, and hence:


will give what you want.  You can, of course, assign this to another
object if you like.  Incidentally, anova(aov.ex)[,4:5] is somewhat more

HTH ....

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Waverley
> Sent: Wednesday, 29 October 2008 1:49 p.m.
> To: r-help at r-project.org; r-help
> Subject: [R] how to get the value of aov summary into another variable
> Hi,
> I have a question of aov.  e.g.
> aov.ex = aov(x~y)
> summary(aov.ex)
> The aov summary will print to the screen.  How can I extract 
> the aov result, in particular the values of Pr(>F) and F 
> value into a vector so that I can use them for other use?
> Thanks.
> --
> Waverley @ Palo Alto
> ______________________________________________
> 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.

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

More information about the R-help mailing list