Skip to content

How can I use the rho value in the cor.test() summary?

5 messages · Hayes, Peter Dalgaard, Daniel Malter

#
x=c(1,2,3,4,5,6,7,8,9)
y=c(3,5,4,6,7,8,8,7,10)

z=cor.test(x,y)

othervariable=z$p.value

Cheers,
Daniel 

-------------------------
cuncta stricte discussurus
-------------------------

-----Urspr?ngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von Hayes
Gesendet: Tuesday, December 04, 2007 2:11 AM
An: r-help at r-project.org
Betreff: [R] How can I use the rho value in the cor.test() summary?


I want to give the "rho" value below to another variable.How ?
--
View this message in context:
http://www.nabble.com/How-can-I-use-the-rho-value-in-the-cor.test%28%29-summ
ary--tf4941501.html#a14145737
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
#
Daniel Malter wrote:
z$statistic, more likely.

  
    
#
Peter Dalgaard wrote:
z$estimate, even more likely.... (D'oh!!!)

  
    
#
My apologies, I was wrong with z$p.value. That is not what you wanted. I
should not write email at 3:30 :) But I think z$statistic as suggested by
Peter is not it either. You said you want the rho. The code for it is
z$estimate, assuming that you used method="spearman" to get a rho . Please
look below. It is othervariable3 that you want. So to get it (hopefully)
fully right once:

x=c(1,2,3,4,5,6,7,8,9)
y=c(3,5,4,6,7,8,8,7,10)

z=cor.test(x,y,method="spearman")

z
othervariable=z$p.value
othervariable2=z$statistic
othervariable3=z$estimate

You can get help for the function by typing ?cor.test . This shows you the
available values returned by cor.test that you can easily assign to other
variables.


-------------------------
cuncta stricte discussurus
-------------------------

-----Urspr?ngliche Nachricht-----
Von: Peter Dalgaard [mailto:p.dalgaard at biostat.ku.dk] 
Gesendet: Tuesday, December 04, 2007 3:33 AM
An: Daniel Malter
Cc: r-help at r-project.org
Betreff: Re: [R] How can I use the rho value in the cor.test() summary?
Daniel Malter wrote:
, more likely.