Remove rows containing string in any vector in data frame
<p>I have a data frame containing a number of vectors that contain strings I would like to remove rows that contain a certain string. </p>

<pre><code>df &lt;- data.frame(id=seq(1:10),
             foo=runif(10),
             sapply(letters[1:5],function(x) {sample(letters,10,T)} ),
             bar=runif(10))
</code></pre>

<p>This can be done on a single vector by specifying the vector name i.e.</p>

<pre><code>df &lt;- df[!grepl("b", df$a),]
</code></pre>

<p>which I can then repeat specifying each vector e.g. </p>

<pre><code>df &lt;- df[!grepl("b", df$b),]
df &lt;- df[!grepl("b", df$c),]
df &lt;- df[!grepl("b", df$d),]
df &lt;- df[!grepl("b", df$e),]
</code></pre>

<p>but is it possible to do it in one line without having to specify which columns contain the string? Something like:</p>

<pre><code>df &lt;- df[!grepl("b", df),]
</code></pre>