Re: [R] correlation and matrix

2007-07-30 Thread Jacques VESLOT
it should be smth like that: apply(sapply(seq(1, 204, by=12), seq, length=4), 2, function(x) { M <- dta[,x] z <- sapply(M, nlevels) # if dta is a dataframe if (sum(z==1)<3) cor(as.matrix(M[,z!=0]), use="comp", method="spear") else NA }) Jacques VESLOT INRA - Biostatistique & Processus Sp

[R] correlation and matrix

2007-07-29 Thread Nathalie.Cornileau
Dear everyone, I am new in R and I've got difficulties in realizing the following tasks: -I have variables (factors) with different numbers of levels, either 1, 2 or 3. -I have a matrix containing these 204 factors and I have to correlate them by groups of 4 variables. -I have to delete the facto