Waverley
2008-Oct-29 00:48 UTC
[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
Peter Alspach
2008-Oct-29 01:00 UTC
[R] how to get the value of aov summary into another variable
Waverley In general, examine the structure of the object and go from there. Thus: str(summary(aov.ex)) 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 list This is a data.frame, and hence: summary(aov.ex)[[1]][,4:5] 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 direct. 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.
Jorge Ivan Velez
2008-Oct-29 01:04 UTC
[R] how to get the value of aov summary into another variable
Dear Waverley, Try # Data x=rnorm(10) y=rep(1:2,5) aov.ex = aov(x~y) tail(unlist(summary(aov.ex)),2) # or anova(lm(x~y))$"Pr(>F)" HTH, Jorge On Tue, Oct 28, 2008 at 8:48 PM, Waverley <waverley.paloalto@gmail.com>wrote:> 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@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. >[[alternative HTML version deleted]]