[R] access elements of summary.aov?

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 19 14:53:24 CEST 2009


It is a 'List of 1', so you want tmp[[1]] which you can access as a 
data frame.  As the help file says

      For a fit with a single stratum the result will be a list of
      ANOVA tables, one for each response (even if there is only one
      response): the tables are of class '"anova"' inheriting from class
      '"data.frame"'.  They have columns '"Df"', '"Sum Sq"', '"Mean
      Sq"', as well as '"F value"' and '"Pr(>F)"' if there are non-zero
      residual degrees of freedom.  There is a row for each term in the
      model, plus one for '"Residuals"' if there are any.

and you have a single response so select the only element of the 
list.

On Mon, 19 Oct 2009, Liviu Andronic wrote:

> Dear all
> How do I access individual elements of a "summary.aov" object?
>> data(iris)
>> AnovaModel.1 <- aov(Sepal.Length ~ Species, data=iris)
>> tmp <- summary(AnovaModel.1)
>> tmp
>             Df Sum Sq Mean Sq F value Pr(>F)
> Species       2   63.2    31.6     119 <2e-16 ***
> Residuals   147   39.0     0.3
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>> str(tmp)
> List of 1
> $ :Classes 'anova' and 'data.frame':	2 obs. of  5 variables:
>  ..$ Df     : num [1:2] 2 147
>  ..$ Sum Sq : num [1:2] 63.2 39
>  ..$ Mean Sq: num [1:2] 31.606 0.265
>  ..$ F value: num [1:2] 119 NA
>  ..$ Pr(>F) : num [1:2] 1.67e-31 NA
> - attr(*, "class")= chr [1:2] "summary.aov" "listof"
>> tmp$1
> Error: unexpected numeric constant in "tmp$1"
>> tmp$"1"
> NULL
>> tmp$""
> NULL
>
> Thank you
> Liviu
>
>
>
>
> -- 
> Do you know how to read?
> http://www.alienetworks.com/srtest.cfm
> Do you know how to write?
> http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list