title: finding the longest stretch of rows of data entries by grouping variable using tidyverse/ other R command
body: <p>I am not sure if I describe my question with the correct title but the idea is:</p>
  <p>I would like to longest stretch of rows of data entries of each group after using <code>group_by()</code> which is also sensitive to the current order of rows. In other words, there are a (or multiple) discontinuities within a group (e.g. after <code>arrange()</code> by some other columns). I would like to get a new column (e.g. <code>mutate()</code>) that labels the rows that are within the longest stretch of each group. below is an example:</p>
  <pre><code>data.frame(group = c(1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 1, 1, 3, 1, 2, 2, 2),
             order = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17))
  </code></pre>
  <p>In which, I would like to get a data frame like the following:</p>
  <pre><code>data.frame(group = c(1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 1, 1, 3, 1, 2, 2, 2),
             order = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17),
             longest = c(T, T, T, F, F, T, T, T, T, T, F, F, F, F, T, T, T))
  </code></pre>