title: Avoid repetition in summarise() using across() or tidyverse
body: <p>I'm trying to use across() or another tidyverse function to simplify the lines that follow the general line of <code>output.partyA = sum(x.partyA) - sum(y.partyA)</code>.</p>
  <p>An example of one of the lines that I did to simplify the number of lines was: <code>across(matches(&quot;^Seats_P_...$&quot;), ~ .x / Dist_Mag, .names = &quot;{str_replace({.col}, '_P_', '_P_Pct_')}&quot;),</code>.</p>
  <p>Here's what I am trying to simplify:</p>
  <pre><code>df %&gt;% 
  group_by(MMD) %&gt;%
  summarise(
        N = n(),
        #taken out for clarity,
        DFP_RCV_DEM = sum(Seats_RCV_Pct_DEM) - sum(SVP_DEM), 
        DFP_RCV_REP = sum(Seats_RCV_Pct_REP) - sum(SVP_REP),
        DFP_RCV_SCT = sum(Seats_RCV_Pct_SCT) - sum(SVP_SCT),
        DFP_RCV_WRT = sum(Seats_RCV_Pct_WRT) - sum(SVP_WRT),
        DFP_RCV_LBT = sum(Seats_RCV_Pct_LBT) - sum(SVP_LBT),
        DFP_RCV_UND = sum(Seats_RCV_Pct_UND) - sum(SVP_UND)
      ) %&gt;%
  ungroup()
  
  </code></pre>