Skip to content

extracting elements from summary(aov object)

7 messages · Peter Dalgaard, Bill Shipley, Thomas Lumley +2 more

#
Bill Shipley <Bill.Shipley at Usherbrooke.ca> writes:
R seems to require an extra [[1]] bit before $"F value". Don't ask me
why...
#
Hello.  When one types "summary(fit)", where fit is an object from a call 
to aov(), one gets an ANOVA table.  I want to save just one element of this 
summary.  How does one extract this?

As an example, here is my output from a split plot ANOVA:

 > summary(out)$"Error: soil.cores$block:soil.cores$treatment"
                      Df  Sum Sq Mean Sq F value Pr(>F)
soil.cores$block      3 0.63626 0.21209  1.0557 0.4147
soil.cores$treatment  3 0.90276 0.30092  1.4978 0.2802
Residuals             9 1.80813 0.20090

I want to save only the F value of "soil.cores$treatment" .  In SPLUS one 
would do this by
summary(out)$"Error: soil.cores$block:soil.cores$treatment"$"F value"[2] 
but this doesn't seem to work.

Thanks.

Bill Shipley
Departement de biologie
Universite de Sherbrooke
Sherbrooke (Quebec) CANADA J1K 2R9
Bill.Shipley at USherbrooke.ca
http://callisto.si.usherb.ca:8080/bshipley/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Tue, 24 Sep 2002, Bill Shipley wrote:

            
It turns out that
   summary(out)$"Error: soil.cores$block:soil.cores$treatment"
is actually a list containing one data frame rather than a data frame, so
something like

aovtable<-summary(out)$"Error: soil.cores$block:soil.cores$treatment"[[1]]
aovtable[2,"F value"]

would work.

	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Is there a simple way to string-concatenate across the rows of a matrix or
data.frame into a vector of strings?  perhaps using paste() or
something like it?

That is, I want to map from something like x2 below:

	> x2 <- data.frame(C1 = letters[1:4], C3=1:4, C3=letters[11:14])
	> x2
	  C1 C3 C3
	1  a  1  k
	2  b  2  l
	3  c  3  m
	4  d  4  n

to something like:

	[1]  "a  1  k"
	[2]  "b  2  l"
	[3]  "c  3  m"
	[4]  "d  4  n"

Sincerely,
Al Kim
Research Scientist
Department of Psychology
University of Washington, Box 351525
Seattle, WA. 98195, USA
E-Mail:  alkim at u.washington.edu;  Tel: (206)543-2395



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
1       2       3       4
"a 1 k" "b 2 l" "c 3 m" "d 4 n"
At 12:45 PM 9/24/2002 -0700, Albert Kim wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Tony Plate <tplate at blackmesacapital.com> writes:
...or even (data frames only):
[1] "a 1 k" "b 2 l" "c 3 m" "d 4 n"

  
    
#
Dalgaard and Plate suggestions both work.  Thanks for the help.
I was tripped up by not realizing that the optional 'collapse' argument of
paste() must be specified.  Otherwise, it defaults to NULL,  which yields:

	> apply(x2, 1, paste)
	     1   2   3   4
	[1,] "a" "b" "c" "d"
	[2,] "1" "2" "3" "4"
	[3,] "k" "l" "m" "n"

-Al
On 24 Sep 2002, Peter Dalgaard BSA wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._