Re: [R] Avoiding loops using 'for' and pairwise comparison of columns

2013-06-24 Thread Blaser Nello
100,ncol(x)) a2[upper.tri(a2)] <- t(a2)[upper.tri(a2)] > identical(a, a2) [1] TRUE Best, Nello -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Kulupp Sent: Montag, 24. Juni 2013 11:02 To: r-help@r-project.org Subject: [R] Avoidi

[R] Avoiding loops using 'for' and pairwise comparison of columns

2013-06-24 Thread Kulupp
Dear R-experts, I'd like to avoid the use of very slow 'for'-loops but I don't know how. My data look as follows (the original data has 1600 rows and 30 columns): # data example c1 <- c(1,1,1,0.25,0,1,1,1,0,1) c2 <- c(0,0,1,1,0,1,0,1,0.5,1) c3 <- c(0,1,1,1,0,0.75,1,1,0.5,0) x <- data.frame(c1,