Re: [R] how to export results of rcorr into excel

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Tue, 11 Nov 2008 17:51:05 +0000 (UTC)

shixin <jasonshi510 <at> hotmail.com> writes:

>
> I try to export the outputs of rcorr into excel. but I got error
message,"cannot coerce class "rcorr" into a
> data.frame". Actually i just need export part of results of this analysis,e.g.
p-values or stat-values.
library(Hmisc)

x <- c(-2, -1, 0, 1, 2)
y <- c(4,   1, 0, 1, 4)
z <- c(1,   2, 3, 4, NA)
v <- c(1,   2, 3, 4, 5)

rc = rcorr(cbind(x,y,z,v))

str(rc) gives

List of 3
 $ r: num [1:4, 1:4] 1 0 1 1 0 ...

  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:4] "x" "y" "z" "v"
  .. ..$ : chr [1:4] "x" "y" "z" "v"

 $ n: int [1:4, 1:4] 5 5 4 5 5 5 4 5 4 4 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:4] "x" "y" "z" "v"
  .. ..$ : chr [1:4] "x" "y" "z" "v"

 $ P: num [1:4, 1:4] NA 1 0 0 1 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:4] "x" "y" "z" "v"
  .. ..$ : chr [1:4] "x" "y" "z" "v"

 So you could write.table or whatever on

 rc$r
 rc$n
 rc$P
 

 Dieter



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. Received on Tue 11 Nov 2008 - 17:58:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 11 Nov 2008 - 18:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive