title: Summarize with custom function while calling values from outside of group
body: <p>I'm trying to summarize multiple columns using <code>summarize_at()</code> with a custom function. The part I'm stuck on is the function <code>ssmd()</code> is meant to take a vector of values from the group established by <code>group_by()</code> and another vector of values from outside this group. </p>
  
  <p>In the example below, <code>x</code> should be a vector for each set of values by <code>Month</code> (varies according to the current group), and <code>y</code> should be a fixed set of values for <code>Month == 5</code>.</p>
  
  <pre><code># custom function
  ssmd &lt;- function(x, y){
    (mean(x, na.rm = TRUE) - mean(y, na.rm = TRUE)) / sqrt(var(x, na.rm = TRUE) + var(y, na.rm = TRUE))
  }
  
  # dataset
  d &lt;- airquality
  
  # this isn't working - trying to find the difference between the mean for each Month and the mean of Month 5, for columns Ozone, Solar.R, Wind, and Temp
  d %&gt;%
    group_by(Month) %&gt;%
    summarize_at(vars(Ozone:Temp), funs(ssmd, x = ., y = .[Month == 5])) %&gt;%
    ungroup()
  </code></pre>
  
  <p>At the moment, this gives the following error: <code>Error in mean(y, na.rm = TRUE) : argument "y" is missing, with no default</code>. So I think I have a syntax error, in addition to being stuck on how to access values from outside the current group.</p>
  
  <p>The expected output is a data frame with one row for each Month and one column for each variable (Ozone, Solar.R, Wind, and Temp).</p>