title: Group and calculate proportion of binomial vector
body: <p>I'm just trying to calculate a proportion of positive samples &quot;1&quot; for each year. Group by year, then sum(binom == &quot;1&quot;) / nrows(binom).</p>
  <pre><code>structure(list(year = c(2012L, 2012L, 2011L, 2012L, 2015L, 2008L, 
  2013L, 2008L, 2010L, 2018L, 2014L, 2018L, 2012L, 2014L, 2016L, 
  2010L, 2015L, 2009L, 2012L, 2008L, 2017L, 2014L, 2008L, 2011L, 
  2013L, 2013L, 2015L, 2010L, 2017L, 2012L), binom = c(0, 1, 0, 
  0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
  1, 0, 0, 0, 0, 0)), class = c(&quot;data.table&quot;, &quot;data.frame&quot;), row.names = c(NA, 
  -30L), .internal.selfref = &lt;pointer: 0x0000022eda621ef0&gt;)
  </code></pre>
  <p>I know this isn't difficult but I'm just not seeing something...</p>
  <pre><code>bi.count &lt;- wi.hog.test %&gt;% group_by(year) %&gt;% summarise(across(proportion = nrow(binom == &quot;1&quot;,) / nrow(binom == &quot;0&quot; | binom == &quot;1&quot;,)))
  </code></pre>