title: Using summarise_each with custom function that depends on month of data being summarized
body: <p>I have a table with 150+ variables for each day spanning 5 years.  I would like to create a daily average summary for each variable for each year-month.  However, if the month is Jan, May, July, September, November or December, I would like to divide the sum of all values by the count - 1.  </p>
  
  <p>dplyr's summarise_each works well for what I want to do.  However, I'm not having success with integrating a custom function into the funs argument:</p>
  
  <pre><code>by.ym &lt;- training %&gt;% filter(Day.W!=1) %&gt;% group_by(training, year=year(Date), month=month(Date))
  
  testb &lt;- summarise_each(by.ym[,-c(1:3)], 
                          funs(. / (if (month %in% c(1, 5, 7, 9, 11, 12)) {
                            sum(.)/(nrow(.)-1)
                          } else mean(.))
                          ))
  </code></pre>
  
  <p>The error message is:</p>
  
  <pre><code>Error: expecting a single value
  In addition: Warning messages:
  1: In if (c(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,  :
    the condition has length &gt; 1 and only the first element will be used
  2: In if (c(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,  :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>