[R] how to extract information from anova results
Joshua Wiley
jwiley.psych at gmail.com
Tue Jul 13 17:10:12 CEST 2010
I think the easiest way is from calling anova() on your aov class
object. For instance
y <- 1:10
x <- runif(10)
my.aov <- aov(y ~ x)
anova(my.aov)["Residuals", "Sum Sq"]
anova(my.aov)["x", "Pr(>F)"]
You can also extract these values from a call to summary(my.aov), but
that output is a list (even for an ANOVA with a single error stratum),
so you'd have to add [[1]] selecting the first (or if there were more
than one whichever you wanted) element of the list.
summary(my.aov)[[1]]["Residuals", "Sum Sq"]
Cheers,
Josh
On Tue, Jul 13, 2010 at 7:35 AM, Luis Borda de Agua <lbagua at gmail.com> wrote:
> Hi,
>
> I have used the instruction aov in the following manner:
>
> res <- aov(qwe ~ asd)
>
> when I typed "res" I get:
> _________
> Call:
> aov(formula = qwe ~ asd)
>
> Terms:
> asd Residuals
> Sum of Squares 0.0708704 0.5255957
> Deg. of Freedom 1 8
>
> Residual standard error: 0.2563191
> Estimated effects may be unbalanced
> _________
>
> I need to access the value of the Sum of Squares (i.e. I want another variable to be equal to it, e.g myvar <- Sum.of.Squares) .
> I tried names(res) to see which values are accessible, but I couldn't find the Sum of Squares. I had a similar problem when I tried to access the p.value which can be readily SEEN using summary(res).
>
> In general, is there an easy way to access the values generated by an R function?
>
> Thank you,
>
> LBA
>
> ______________________________________________
> 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.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list