title: How do i use grepl on each column in a data frame?
body: <p>I have some values in my data frames #N/A that I want to convert to NA. I'm trying what seems like a straightforward grepl via lapply on the data frame, but its not working. Here's a simple example...</p>
  
  <pre><code>a = c("#N/A", "A", "B", "#N/A", "C")
  b = c("d", "#N/A", "e", "f", "123")
  df = as.data.frame(cbind(a,b))
  lapply(df, function(x){x[grepl("#N/A", x)]=NA})
  </code></pre>
  
  <p>Which outputs:</p>
  
  <pre><code>$a
  [1] NA
  
  $b
  [1] NA
  </code></pre>
  
  <p>Can someone point me in the right direction? I'd appreciate it.</p>