quote the variable name or index the results from anova as a dataframe using [. Someone (Prof. Ripley IIRC, apologies if I got this wrong) once told me that backticks ` are the preferred, portable way of doing this, but in this case " quotes work as well.
> example(anova.lm) ## produces fit > tmp <- anova(fit) > str(tmp) ## notice the Classes line below Classes ‘anova’ and 'data.frame': 5 obs. of 5 variables: $ Df : int 1 1 1 1 45 $ Sum Sq : num 204.1 53.3 12.4 63.1 650.7 $ Mean Sq: num 204.1 53.3 12.4 63.1 14.5 $ F value: num 14.116 3.689 0.858 4.360 NA $ Pr(>F) : num 0.000492 0.061125 0.359355 0.042471 NA - attr(*, "heading")= chr "Analysis of Variance Table\n" "Response: sr" > tmp$`Pr(>F)` [1] 0.0004921955 0.0611254598 0.3593550848 0.0424711387 NA > tmp$"Pr(>F)" [1] 0.0004921955 0.0611254598 0.3593550848 0.0424711387 NA > tmp[,5] [1] 0.0004921955 0.0611254598 0.3593550848 0.0424711387 NA ##drop the last entry corresponding to the row for Residuals: > tmp[1:4,5] [1] 0.0004921955 0.0611254598 0.3593550848 0.0424711387 This has nothing to do with S3 or S4, just knowing how to reference non-standard (probably not the correct terminology) names. HTH G On Wed, 2008-05-07 at 18:17 -0700, H. Paul Benton wrote: > Yea the anova object seems to be odd. It's not S4 so that's why I > tried originally the attr() funtion but.... > > summary(pb)$Pr(>F) > > Error: unexpected '>' in "summary(pb)$Pr(>" > > summary(pb)$Pr > > NULL > > summary(pb)@Pr(>F) > > Error: unexpected '>' in "summary(pb)@Pr(>" > > summary(pb)@Pr(F) > > Error: no slot of name "Pr" for this object of class "summary.aov" > In addition: Warning message: > trying to get slot "Pr" from an object (class "summary.aov") that is > not an S4 object > > > > Research Programmer & Technician > The Scripps Research Institute > Mass Spectrometry Core Facility > o The > / > o Scripps > \ > o Research > / > o Institute > > > > [EMAIL PROTECTED] wrote: > > Hi: it's probably the Pr(> F) element so just access it by > > > > sum<-summary(whatever). > > > > then sum$Pr(>F) will probably work. But make sure that's it because > > usually the name is pval or pvalue etc so I'm > > surprised about the weird name. > > > > > > > > > > On Wed, May 7, 2008 at 8:47 PM, Paul Benton wrote: > > > >> hello all, > >> > >> Quick question, how do I get the p value out of the anova? > >> > >> Thanks, > >> > >> Paul > >> > >>> pb<-aov(as.numeric(diff[5,16:33]) ~ grF) > >>> summary(pb) > >> Df Sum Sq Mean Sq F value Pr(>F) > >> grF 3 2.7860e+10 9.2867e+09 4.2236 0.02534 * > >> Residuals 14 3.0783e+10 2.1988e+09 > >> --- > >> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > >>> str(summary(pb)) > >> List of 1 > >> $ :Classes 'anova' and 'data.frame': 2 obs. of 5 variables: > >> ..$ Df : num [1:2] 3 14 > >> ..$ Sum Sq : num [1:2] 2.79e+10 3.08e+10 > >> ..$ Mean Sq: num [1:2] 9.29e+09 2.20e+09 > >> ..$ F value: num [1:2] 4.22 NA > >> ..$ Pr(>F) : num [1:2] 0.0253 NA > >> - attr(*, "class")= chr [1:2] "summary.aov" "listof" > >>> attr(summary(pb), "Pr(>F)") > >> NULL > >> > >> ______________________________________________ > >> 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]] > > ______________________________________________ > 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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ 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.