title: Exclude rows from data.frame depending on a subset of the data.frame
body: <p>I have the following simulated data.frame:</p>
  
  <p>(please note that I have re-written large portions of the question, reflecting akrun's answer to my initial question)</p>
  
  <pre><code>set.seed(22)
  df &lt;- data.frame(f1 = rep("a", 20), f2 = factor(sample(c("yes", "no", "maybe", "maybenot"), 20, replace = T)), f3 = factor(sample(c("yes", "no"), 20, replace = T)), f4 = factor(sample(c("yes", "no"), 20, replace = T)))
  
     f1       f2  f3  f4
  1   a    maybe yes yes
  2   a       no yes yes
  3   a      yes  no  no
  4   a    maybe yes  no
  5   a    maybe  no yes
  6   a maybenot  no yes
  ...
  </code></pre>
  
  <p>I would like to exclude all rows that do <strong>not</strong> show a <code>yes</code> in <code>df$f2</code>, and show a <code>no</code>in either <code>df$f3</code>, or <code>df$f4</code>. If I would manually transform the values into 0s and 1 (0 for everything except <code>yes</code>in <code>df$f2</code>), I could use <code>rowSums</code> as suggested by akrun. My current solution is to introduce a dummy column called <code>df$exclude</code> as follows and then to <code>subset</code> on <code>df$exclude</code>:</p>
  
  <pre><code>df$exclude &lt;- "no"
  df[df$f2 != "yes" | df$f3 == "no" | df$f4 == "no",]$exclude &lt;- "yes"    
  df &lt;- subset(df, exclude == "no")
  </code></pre>
  
  <p>Can't this be accomplished more concisely, e.g. without a prior transformation of the columns f2, f3, and f3, or by using <code>lapply</code> (somehow combined with <code>subset</code>, and possibly an anonymous function)? </p>
  
  <p>Thanks in advance for your answers.</p>