[R] Indexing in anova summary output of the form: summary(aov(y ~ x1, Error = (x1/x2)))
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Apr 5 20:36:58 CEST 2007
The output is of class "summary.anovalist" so (hint, hint) it is a list.
Try [[ ]] to get list elements.
Without a reproducible example (see the footer and the posting guide) it
is not possible to show you working code.
On Thu, 5 Apr 2007, Michael D. Rennie wrote:
>
> Hi, there
>
> I'm trying to get the value of the Mean Square from the ANOVA model summary
> that comes from specifying the error term, and am wondering if one can
> actually do this ( I know it's possible when using anova(lm) objects and the
> like, but I'm having a tough time with it under this framework). There does
> appear to be some indexing in the output of this type, but perhaps not enough
> to obtain single values? Here's what I've been able to do so far with some
> example code:
>
>> density.aov<-aov(density ~ substrate + Error(substrate/tile))
>>
>> anov1<-(summary(density.aov))
>> print(anov1)
>
> Error: substrate
> Df Sum Sq Mean Sq
> substrate 2 1282.4 641.2
>
> Error: substrate:tile
> Df Sum Sq Mean Sq F value Pr(>F)
> Residuals 27 225.700 8.359
> Error: Within
> Df Sum Sq Mean Sq F value Pr(>F)
> Residuals 60 640.00 10.67
>> anov1[1]
> $`Error: substrate`
> Df Sum Sq Mean Sq
> substrate 2 1282.4 641.2
>
>> anov1[2]
> $`Error: substrate:tile`
> Df Sum Sq Mean Sq F value Pr(>F)
> Residuals 27 225.700 8.359
> And, I can get
>
>> anov1[1]$Error
> Df Sum Sq Mean Sq
> substrate 2 1282.4 641.2
>
> a<-anov1[1]$Error
>
> and then tried to get at elements in that, trying things like
>
> a$Mean
>
> or
>
> a[,2]
>
> but all return
>
> Error: incorrect number of dimensions
>
> probably because
>
>> length(a)
> [1] 1
>
> Does anyone have any reccomendations on how to go any further here?
>
> Cheers,
>
> Mike
>
>
--
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