[R] Problem with differences between S+ and R in parsing output tables with $
Ben Bolker
ben at zoo.ufl.edu
Mon Dec 9 20:38:02 CET 2002
In R, it looks like the "summary.aov" type actually contains the data
frame you're trying to extract as the first (and only) element of a list,
so
summary(aov(model))[[1]]
is more or less equivalent to the summary(aov(model)) object in S-PLUS,
and
summary(aov(model))[[1]]$"Pr(>F)"[1]
gets the specific number you're looking for.
str() and class() are the tools for disentangling this kind of problem.
It is a shame that it's so hard to extract the value in this case, but the
authors have to be able to structure things internally however they find
convenient, and unless they provide accessor methods for everything anyone
could conceivably want, people are going to have to dig at some point ...
On Mon, 9 Dec 2002, RexBryan wrote:
> R-wizards
>
> I have successfully run with S+ a statistical power calculation for
> non-normal distributions as presented in M. Crawleys new book. When I
> tried the newest version of R on the same code, the $ parse statement
> doesn't seem to retrieve the appropriate number from a table. Note that
> some of the cosmetic differences in the two tables have to be dealt with
> by the parser. Any ideas what's happening?
> REX
>
> # Begin R -------------------------------------------------------------
> #
> > summary(aov(model))
>
> Df Sum Sq Mean Sq F value Pr(>F)
> fa 1 11.1 11.1 0.9327 0.3345
> Residuals 698 8279.3 11.9
>
> # R: ... trying to parse the table gives a NULL for the probability of
> F...
>
> > (summary(aov(model))$"Pr(>F)")[1]
> NULL
>
> # End R ---------------------------------------------------------------
>
> # Begin S+ ------------------------------------------------------------
>
> > summary(aov(model))
>
> Df Sum of Sq Mean Sq F Value
> Pr(F)
> fa 1 11.063 11.06286 0.9326708
> 0.3345044
> Residuals 698 8279.314 11.86148
>
> # S+ ... using $ to parse the table gives the right answer for the
> probability of F...
>
> (summary(aov(model))$"Pr(F)")[1]
> [1] 0.3345044
>
> # End S+ --------------------------------------------------------------
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
--
318 Carr Hall bolker at zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
Box 118525 (ph) 352-392-5697
Gainesville, FL 32611-8525 (fax) 352-392-3704
More information about the R-help
mailing list