Try this:

y <- data.frame(a=sample(30, 20), b=sample(30, 20), c=sample(30,20))
x <- diag(1, length(names(y))
cors <- combn(names(y), 2,
           FUN = function(x)cor.test(y[,x[1]], y[,x[2]])$p.value)
x[lower.tri(x)] <- cors
x[upper.tri(x)] <- cors




On 5/2/08, Sang Chul Choi <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Is there a simple way to do correlation coefficient tests with "cor.test"
> like I would do with "cor" function? I have a data frame where each column
> is a list.
>
> ================================================
> y <- data.frame(a=sample(30, 20), b=sample(30, 20), c=sample(30,20))
> cor(y)
> ================================================
>
> But, cor.test does not take y alone, and it needs two vectors. We may do
> each test by iterating a pair of columns by loop. Is there a simple way to
> do it? I will appreciate your help.
>
> Thank you,
>
> Sang Chul
>
> ______________________________________________
> R-help@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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to