title: Select rows from a data frame based on values in a vector
body: <p>I have data similar to this:</p>
  
  <pre><code>dt &lt;- structure(list(fct = structure(c(1L, 2L, 3L, 4L, 3L, 4L, 1L, 2L, 3L, 1L, 2L, 3L, 2L, 3L, 4L), .Label = c("a", "b", "c", "d"), class = "factor"), X = c(2L, 4L, 3L, 2L, 5L, 4L, 7L, 2L, 9L, 1L, 4L, 2L, 5L, 4L, 2L)), .Names = c("fct", "X"), class = "data.frame", row.names = c(NA, -15L))
  </code></pre>
  
  <p>I want to select rows from this data frame based on the values in the <code>fct</code> variable. For example, if I wish to select rows containing either "a" or "c" I can do this:</p>
  
  <pre><code>dt[dt$fct == 'a' | dt$fct == 'c', ]
  </code></pre>
  
  <p>which yields </p>
  
  <pre><code>1    a 2
  3    c 3
  5    c 5
  7    a 7
  9    c 9
  10   a 1
  12   c 2
  14   c 4
  </code></pre>
  
  <p>as expected. But my actual data is more complex and I actually want to select rows based on the values in a vector such as</p>
  
  <pre><code>vc &lt;- c('a', 'c')
  </code></pre>
  
  <p>So I tried</p>
  
  <pre><code>dt[dt$fct == vc, ]
  </code></pre>
  
  <p>but of course that doesn't work. I know I could code something to loop through the vector and pull out the rows needed and append them to a new dataframe, but I was hoping there was a more elegant way.</p>
  
  <p>So how can I filter/subset my data based on the contents of the vector <code>vc</code>?</p>