Dear all, I have a matrix X with 47 lines and say 500 columns - values are in {0,1}. I'd like to compare lines.
For that, I first did: for (i in 1:(dim(X)[1]-1)) for (j in (i+1):dim(X)[1]) { Y <- X[i,]+Y[j,] etc. but, since it takes a long time, I would prefer avoding loops; for that, my first idea was to add this matrix: X1=X[,rep(1:46,46:1)] to this one: res=NULL for (i in (2:47)) res=c(res,i:47) X2=X[,res] (Is it a nice alternative way ?) Is there a way to create the second matrix X2 without a loop, such as for X1 ? Thanks in advance, Jacques VESLOT ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html