title: Summarize with dplyr "other then" groups
body: <p>I need to summarize in a grouped data_frame (warn: a solution with dplyr is very much appreciated but isn't mandatory) both something on each group (simple) and the same something on "other" groups.</p>
  
  <p>minimal example</p>
  
  <pre><code>if(!require(pacman)) install.packages(pacman)
  pacman::p_load(dplyr)
  
  df &lt;- data_frame(
      group = c('a', 'a', 'b', 'b', 'c', 'c'),
      value = c(1, 2, 3, 4, 5, 6)
  )
  
  res &lt;- df %&gt;%
      group_by(group) %&gt;%
      summarize(
          median        = median(value)
  #        median_other  = ... ??? ... # I need the median of all "other"
                                       # groups
  #        median_before = ... ??? ... # I need the median of groups (e.g
                                   #    the "before" in alphabetic order,
                                   #    but clearly every roule which is
                                   #    a "selection function" depending
                                   #    on the actual group is fine)
      )
  </code></pre>
  
  <p>my expected result is the following</p>
  
  <pre><code>group    median    median_other    median_before
    a        1.5         4.5               NA
    b        3.5         3.5               1.5
    c        5.5         2.5               2.5
  </code></pre>
  
  <p>I've searched on Google strings similar to "dplyr summarize excluding groups", "dplyr summarize other then group",I've searched on the dplyr documentation but I wasn't able to find a solution.</p>
  
  <p>here, this (<a href="https://stackoverflow.com/questions/34327780/how-to-summarize-value-not-matching-the-group-using-dplyr">How to summarize value not matching the group using dplyr</a>) does not apply because it runs only on sum, i.e. is a solution "function-specific" (and with a simple arithmetic function that did not consider the variability on each group). What about more complex function request (i.e. mean, sd, or user-function)? :-)</p>
  
  <p>Thanks to all</p>
  
  <p>PS: <code>summarize()</code> is an example, the same question leads to <code>mutate()</code> or other dplyr-functions working based on groups.</p>