I am programming in R and I have two matrices, like this
a:    x1     x2                 b:   x1
      5      3                       3
      5      10                      5
      7      3                       7 
      7      140                     8
      10     152                     10
      ...    ...                     ...
I want to remove all rows in b, where b$x1 is neither the same as any a$x1 or b$x1. If the x1 of matrix b is the same as any x1 or x2 in a, then it should stay in matrix b. The matrices also have other columns, but they are not interesting for this operation.
Can anybody help me?
 
     
    