Let\'s say I have a matrix x which contains 10 rows and 2 columns. I want to generate a new matrix M that contains each unique pair of rows from
x
M
Using Dirk's answer:
idx <- expand.grid(1:nrow(x), 1:nrow(x)) idx<-idx[idx[,1] >= idx[,2],] N <- cbind(x[idx[,2],], x[idx[,1],]) > all(M == N) [1] TRUE
Thanks everyone!