title: Deleting rows and columns of a data frame based on values of another data frame
body: <p>I want to print the rows and columns of a large data frame in which the values appear also in a given row or column of another data frame. I am trying a for loop based on the coincidence with a list of values, without success. A simplified example:</p>
  
  <p>Given the data frame </p>
  
  <pre><code>r1&lt;-c(1,2,3,4,5)
  r2&lt;-c(6,7,8,9,10)
  r3&lt;-c(11,12,13,14,15)
  r4&lt;-c(16,17,18,19,20)
  r5&lt;-c(21,22,23,24,25)
  sample&lt;-as.data.frame(rbind(r1,r2,r3,r4,r5))
  
          V1  V2  V3  V4  V5
     r1   1   2   3   4   5
     r2   6   7   8   9   10
     r3   11  12  13  14  15
     r4   16  17  18  19  20
     r5   21  22  23  24  25
  </code></pre>
  
  <p>I want to erase the columns of "sample" in which the values of the first row r1 do not appear in </p>
  
  <pre><code>info.column&lt;-as.data.frame(c(6,1,4,21,15,11,9,12,13,14,15))
  </code></pre>
  
  <p>and to erase the rows in which the values of the first column V1 do not appear in</p>
  
  <pre><code>info.row&lt;-as.data.frame(c(1,11,3,7,5,21,2))
  </code></pre>
  
  <p>The expected result would be</p>
  
  <pre><code>            V1  V4
         r1   1   4
         r3   11  14
         r5   21  24
  </code></pre>
  
  <p>Any suggestion?</p>