title: Using one data frame as a mask for extracting data from another data frame in R
body: <p>I am new to R and I'm struggling with a data formation issue. I'm attempting to extract a set of values from a data frame by using a separate data frame as the criteria for my selection.</p>
  
  <p>As an example, here is my original data:</p>
  
  <pre><code>Raw Data:
  
  1 A  B  C  D  E  F
  2 25 52 33 92 83 14
  3 23 31 13 13 53 34
  4 13 53 23 89 35 93
  5 89 90 91 91 90 89
  </code></pre>
  
  <p>I'm trying to use a data frame of the same size similar to the following to "filter" that data:</p>
  
  <pre><code>Data Frame "mask":
  
  1 08 09 10 08 09 10
  2  1  2  3  4  1  2
  3  1  2  3  4  1  2
  4  2  3  4  1  2  3
  5  2  3  4  1  2  3
  </code></pre>
  
  <p>For this example, I would like to form a vector from values in the raw data whos corresponding value in the data frame "mask" is equal to 1 and when the first row in the mask is equal to 8. In this case the result would be:</p>
  
  <pre><code>res = c(25, 23, 89, 91)
  </code></pre>
  
  <p>As I said, I'm relatively new to R and I have found that the simplest questions tend to be the most difficult to find answers for since most people don't have to ask them.. So hopefully this is a simple problem. =)</p>
  
  <p>If this has been discussed elsewhere, a link would be very helpful. Otherwise any help is greatly appreciated.</p>