title: How to summarize pairwise counts based on multiple columns in R?
body: <p>In my dataset, I have plant counts for several months <code>time</code> across few sites <code>sites</code>. I identified plant species <code>who</code> and measured flowers <code>vals</code>. Notice is some sites only few species flower (May Site 1 and 2) and all species in others (June) for a given month.
  I am first trying to subset this data for only three species of inters &quot;A&quot;,&quot;B&quot; and &quot;C&quot;</p>
  <pre><code>time &lt;- c(&quot;May&quot;,&quot;May&quot;,&quot;May&quot;,&quot;May&quot;,&quot;May&quot;,&quot;May&quot;,&quot;May&quot;,&quot;May&quot;,&quot;Jun&quot;,&quot;Jun&quot;,&quot;Jun&quot;,&quot;Jun&quot;)
  site &lt;- c(1,1,1,1,2,2,2,2,1,1,1,1)
  who &lt;- c(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;)
  val &lt;- c(12,0,1,2,4,6,0,8,10,2,10,2)
  
  df.test &lt;- data.frame(time, site, who, val)
  
  #First Need to subset rows containing `who` A, B and C
  df.test &lt;- df.test[df.test$who == c(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;), ]
   Error: I am not sure why its only picking up only from site 1. I am looking for 9 rows not 3
  time site who val
   1   May 1   A  12
   2   May 1   B   0
   3   May 1   C   1
  </code></pre>
  <p>Then, based on this correct subset of data I want to find counts of how many unique sites (unique in time, and site) have only positive, non-zero values of A and B; A and C; B and C; A,B,C?</p>
  <pre><code>A and B only = 1
  A and C only = 1
  B and C only = 0
  A, B and C only = 1
  </code></pre>