title: R get rows based on multiple conditions - use dplyr and reshape2
body: <pre><code>df &lt;- data.frame(
      exp=c(1,1,2,2),
    name=c("gene1", "gene2", "gene1", "gene2"),
      value=c(1,1,3,-1)
      )
  </code></pre>
  
  <p>In trying to get customed to the <code>dplyr</code> and <code>reshape2</code>I stumbled over a "simple" way to select rows based on several conditions. If I want to have those genes (the <code>name</code>variable) that have <code>value</code>above 0 in experiment 1 (<code>exp</code>== 1) AND at the same time <code>value</code>below 0 in experiment 2; in df this would be "gene2". Sure there must be many ways to this, e.g. subset df for each set of conditions (exp==1 &amp; value > 0, and exp==2 and value &lt; 0) and then join the results of these subset:</p>
  
  <pre><code>library(dplyr)    
  inner_join(filter(df,exp == 1 &amp; value &gt; 0),filter(df,exp == 2 &amp; value &lt; 0), by= c("name"="name"))[[1]]
  </code></pre>
  
  <p>Although this works it looks very akward, and I feel that such conditioned filtering lies at the heart of <code>reshape2</code> and <code>dplyr</code> but cannot figure out how to do this. Can someone enlighten me here?  </p>