Dear mailing list, how can I identify all those rows of matrix B which fulfill some condition based on another matrix A? More precisely,
A <- matrix(c(1, 1, 0, 1, -9, 1, -9, 1, 0, 0, 1, 1, 0, -9, 1, 0, -9, 0, 1, 1, 1, -9, 1, 1, 1), ncol = 5, byrow = TRUE) B <- matrix(c(0,0,1,0,0,0,1,1,0,0,0,0,1,1,0,1,0,1,1,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1, 0,1,0,1,0,1,1,0,1,1,1,1,0,1,0,0,1,1,1,0,1,1,1,1,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1), ncol = 5, byrow = TRUE) Row 1 in A has value 1 on element 1, 2 and 4. Which rows in B also display this pattern? Only row 6. Row 2 in A has value 1 on element 1 and 3. Which rows in B also display this pattern? Rows 4, 6, 8 and 10. ... Row 5 in A ... C <- rbind(4, 6, 8, 10, ...) How can I collect together all those rows from B to create a new matrix C? Thanks a lot, Alrik ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.