title: grep on any cell in a data.frame
body: <p>A simple "is there a better way" question. I want to find if any cell in a data.frame contains the sub-string I'm looking for:</p>
  
  <pre><code>d=data.frame(V1=c("xxx","yyy","zzz"), V2=c(NA,"ewruinwe",NA))
  grepl("ruin",d[2,2])  #TRUE
  grepl("ruin",d)  #FALSE FALSE
  any(grepl("ruin",as.character(as.matrix(d))))   #TRUE
  </code></pre>
  
  <p>The last line does what I want, but it looks so ugly I'm wondering if I'm missing something simpler.</p>
  
  <p>Background: <code>d</code> is one of the elements in <code>t=readHTMLTable(url)</code> (XML package). I was doing the d[2,2] approach, to check for an error message, and just discovered the website sometimes add another row to the HTML table, pushing the error message I was looking for to another cell.</p>
  
  <p>UPDATE: so, it seems the two choices (thanks to mathematical.coffee and Roman Luštrik) are:</p>
  
  <pre><code>any(grepl("ruin",as.matrix(d)))
  any(apply(d, 2, function(x) grepl("ruin", x)))
  </code></pre>