title: Calculating average time difference by group using dplyr
body: <p>Say I have the following data frame representing the dates users registered an application in various companies:</p>
  
  <pre><code>df &lt;- data.frame(user = c("Tia", "Sam", "Matt", "Brandy", "Joe", "Nariko"),
                   company = c("Intel", "Intel", "Nvidia", "Nvidia", "Nvidia", "Google"),
                   registrationDate = as.Date(c("2015-01-04", "2015-01-04", "2015-01-19", 
                                                "2015-01-20", "2015-01-20", "2015-01-25")),
                   stringsAsFactors = FALSE)
  </code></pre>
  
  <p>How do I create a vector that would give me the average time difference between users at each company to register the application?</p>
  
  <p>I am having some trouble getting simple summary statistics by company over the date variable. For example, when I try to find the maximum registration date for each company using dplyr: </p>
  
  <pre><code>library(dplyr)
  df %&gt;% 
    group_by(company) %&gt;%
    mutate(maxDate = max(registrationDate))
  </code></pre>
  
  <p>I get the maximum date over the entire registrationDate vector replicated for each row in the data frame. It is as though the max() function ignores dplyr's piping. </p>