title: How to find the range of dates for each group in a dataframe
body: <p>Consider this data frame:</p>
  <pre class="lang-r prettyprint-override"><code>data &lt;- data.frame(group = rep(letters[1:3], c(4,5,4)),
                  Date = as.Date(c(&quot;2010-08-09&quot;, &quot;2010-09-11&quot;, &quot;2010-09-12&quot;, &quot;2010-09-18&quot;,
                                   &quot;2014-03-15&quot;,&quot;2014-03-16&quot;,&quot;2014-03-20&quot;,&quot;2014-03-21&quot;,&quot;2014-03-25&quot;,
                                   &quot;2016-05-02&quot;,&quot;2016-08-02&quot;,&quot;2016-08-03&quot;,&quot;2016-09-21&quot;)))
  </code></pre>
  <p>We have three groups with observations that were taken on various dates. I want to find the first and last date for each group (preferably using <code>dplyr</code>). How can this be done with dates?</p>
  <p>Edit:
  I am adding this to clarify my reason for asking, which has to do with R's ability to interpret real time (dates). <code>data2</code> will be the exact same as <code>data</code> above, but notice that I switch the first two dates, so that the observations for <code>group==a</code> are no longer in real temporal order (from earliest to latest, in relation to real time):</p>
  <pre class="lang-r prettyprint-override"><code>data2 &lt;- data.frame(group = rep(letters[1:3], c(4,5,4)),
                  Date = as.Date(c(&quot;2010-09-11&quot;,&quot;2010-08-09&quot;, &quot;2010-09-12&quot;, &quot;2010-09-18&quot;,
                                   &quot;2014-03-15&quot;,&quot;2014-03-16&quot;,&quot;2014-03-20&quot;,&quot;2014-03-21&quot;,&quot;2014-03-25&quot;,
                                   &quot;2016-05-02&quot;,&quot;2016-08-02&quot;,&quot;2016-08-03&quot;,&quot;2016-09-21&quot;)))
  </code></pre>
  <p>So September 11, 2010 comes after August 9, 2010 (real time), but they are not in this temporal order in the data frame.
  Now if we do:</p>
  <pre class="lang-r prettyprint-override"><code>library(dplyr)
  data2%&gt;%group_by(group) %&gt;% summarise(FirsDate=first(Date),LastDate=last(Date))
  </code></pre>
  <p>We get:</p>
  <pre class="lang-r prettyprint-override"><code>  group FirsDate   LastDate  
    &lt;fct&gt; &lt;date&gt;     &lt;date&gt;    
  1 a     2010-09-11 2010-09-18
  2 b     2014-03-15 2014-03-25
  3 c     2016-05-02 2016-09-21
  </code></pre>
  <p>So it returned the first and last observations, not in true temporal order.</p>