Skip to content
Prev 82155 / 398502 Next

loop problem

you could consider something like this:

A <- matrix(rnorm(100 * 3), 100, 3); colnames(A) <- letters[1:3]
B <- matrix(rnorm(100 * 5), 100, 5); colnames(B) <- letters[4:8]
####
z <- matrix( 0, ncol(A), ncol(B), dimnames = list(colnames(A), 
colnames(B)) )
for(i in 1:ncol(A)){
    z[i, ] <- apply(B, 2, function(x, y) cor.test(x, y)$p.value, y = 
A[, i])
}
z


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Frank Johannes" <fjohannes at fastmail.fm>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, December 05, 2005 4:28 PM
Subject: [R] loop problem
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm