Hi, Try: ##Assuming X and Y are matrices (as stated) Y[!Y %in% X,,drop=FALSE] # ? ? numberall #[1,] "gen3" ? #[2,] "gen4" ? #[3,] "genx4" ? A.K. I would like to exclude entire lines in matrix "Y" based in 2 collumns in matrix "X": Matrix "X": ? number1 ?number2 ? ?gen1 ? ? genx1 ? ? ?gen1 ? ? genx2 ? ?gen2 ? ? genx3 ? ?gen2 ? ? genx5 Matrix "Y": ? ?numberall ? ? gen1 ? ? genx1 ? ? gen2 ? ? genx2 ? ? gen3 ? ? genx3 ? ? gen4 ? ? genx4 Expected output matrix ? ?numberall ? ? gen3 ? ? gen4 ? ? gen4x Cheers.