Hi:

str() is usually helpful:
> str(summary(aov.ex2))
List of 1
 $ :Classes ‘anova’ and 'data.frame':   4 obs. of  5 variables:
  ..$ Df     : num [1:4] 1 1 1 12
  ..$ Sum Sq : num [1:4] 76.5625 5.0625 0.0625 311.25
  ..$ Mean Sq: num [1:4] 76.5625 5.0625 0.0625 25.9375
  ..$ F value: num [1:4] 2.95181 0.19518 0.00241 NA
  ..$ Pr(>F) : num [1:4] 0.111 0.666 0.962 NA
 - attr(*, "class")= chr [1:2] "summary.aov" "listof"

summary.lm() outputs a list object with one component and five
subcomponents.  [[1]] extracts the first component of the list;
[[1]][5] extracts the fifth subcomponent.

This suggests either of the following ways to extract the p-values:

# By component number
> summary(aov.ex2)[[1]][5]
              Pr(>F)
Gender        0.1114
Dosage        0.6665
Gender:Dosage 0.9617
Residuals

# By name
> summary(aov.ex2)[[1]]$'Pr(>F)'
[1] 0.1114507 0.6664956 0.9616567        NA

HTH,
Dennis

On Mon, May 10, 2010 at 12:17 AM, Yuan Jian <jayuan2...@yahoo.com> wrote:

> Hi there,
>
> I checked google for aov. usually one uses summary to see whether the
> p-value is small.
> but I want to put aov in my script. how can I get the p-value, (0.1115,
> 0.6665, 0.6665 in the following example)?
>
> thanks
> YU
>
>
>
> > datafilename="http://personality-project.org/r/datasets/R.appendix2.data
> "
> > data.example2=read.table(datafilename,header=T)
> > aov.ex2 = aov(Alertness~Gender*Dosage,data=data.example2)
> > summary(aov.ex2)
>               Df  Sum Sq Mean Sq F value Pr(>F)
> Gender         1  76.562  76.562  2.9518 0.1115
> Dosage         1   5.062   5.062  0.1952 0.6665
> Gender:Dosage  1   0.063   0.063  0.0024  0.6665
> Residuals     12 311.250  25.938
>
>
>
>
>
>        [[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.
>
>

        [[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.

Reply via email to