title: Finding rows containing a value (or values) in any column
body: <p>Say we have a table 'data' containing Strings in several columns. We want to find the indices of all rows that contain a certain value, or better yet, one of several values. The column, however, is unknown.</p>
  
  <p>What I do, at the moment, is:</p>
  
  <pre><code>apply(df, 2, function(x) which(x == "M017"))
  </code></pre>
  
  <p>where df = </p>
  
  <pre><code>1 04.10.2009 01:24:51   M017  &lt;NA&gt;  &lt;NA&gt;    NA
  2 04.10.2009 01:24:53   M018  &lt;NA&gt;  &lt;NA&gt;    NA
  3 04.10.2009 01:24:54   M051  &lt;NA&gt;  &lt;NA&gt;    NA
  4 04.10.2009 01:25:06   &lt;NA&gt;  M016  &lt;NA&gt;    NA
  5 04.10.2009 01:25:07   &lt;NA&gt;  M015  &lt;NA&gt;    NA
  6 04.10.2009 01:26:07   &lt;NA&gt;  M017  &lt;NA&gt;    NA
  7 04.10.2009 01:26:27   &lt;NA&gt;  M017  &lt;NA&gt;    NA
  8 04.10.2009 01:27:23   &lt;NA&gt;  M017  &lt;NA&gt;    NA
  9 04.10.2009 01:27:30   &lt;NA&gt;  M017  &lt;NA&gt;    NA
  10 04.10.2009 01:27:32   M017  &lt;NA&gt;  &lt;NA&gt;    NA
  11 04.10.2009 01:27:34   M051  &lt;NA&gt;  &lt;NA&gt;    NA
  </code></pre>
  
  <p>This also works if we try to find more than one value:</p>
  
  <pre><code>apply(df, 2, function(x) which(x %in% c("M017", "M018")))
  </code></pre>
  
  <p>The result being:</p>
  
  <pre><code>$`1`
  integer(0)
  
  $`2`
  [1]  1  2 20
  
  $`3`
  [1] 16 17 18 19
  
  $`4`
  integer(0)
  
  $`5`
  integer(0)
  </code></pre>
  
  <p>However, processing the resulting list of lists is rather tedious. </p>
  
  <p>Is there a more efficient way to find rows that contain a value (or more) in ANY column?</p>