Skip to content
Prev 75548 / 398502 Next

Vector comparison to matrix

On Mon, 15 Aug 2005, Prof Brian Ripley wrote:

            
If your matrix A really does have short rows like c(1,2,3) and millions of 
them, another idea is to do

target <- rep(c(1,2,3), each= nrow(A))
rowSums(A != target) == 0

For wider rows my first suggestion is probably faster.