title: In R: Create a data frame which includes consecutive observations only and a variable indicating sequence number
body: <p>I have a data frame with column names similar to below, in which each row is one observation:
  user_id; date; Var_1; Var_2</p>
  <p>Each user_id can have 0 or 1 observations for each date. Only dates with an observation are included in the data frame for each user.</p>
  <p>From this data, I want to create a data frame containing these variables (and the ones described below) but it should only contain observations for 3 successive dates (for each user). Days in each succession should be numbered 1 to 3 and each succession should be numbered as well.</p>
  <p>For instance if user with user_id == 1 has observations on the following date: 2020-01-01, 2020-01-03, 2020-01-04, 2020-01-05, 2020-01-06, 2020-01-10, 2020-01-12, 2020-01-13, 2020-01-14.
  And user with user_id == 2 has observations on the following dates: 2020-01-01, 2020-01-03, 2020-01-04, 2020-01-06, 2020-01-10, 2020-01-12, 2020-01-15, 2020-01-16, 2020-01-17</p>
  <p>Then the new data frame should include:</p>
  <p>user_id      date      Sequence      Day      Var_1      Var_2      <br>
  1            20-01-03      1                  1            <em>value</em>            <em>value</em>      <br>
  1            20-01-04      1                  2            <em>value</em>            <em>value</em>      <br>
  1            20-01-05      1                  3            <em>value</em>            <em>value</em>      <br>
  1            20-01-04      2                  1            <em>value</em>            <em>value</em>      <br>
  1            20-01-05      2                  2            <em>value</em>            <em>value</em>      <br>
  1            20-01-06      2                  3            <em>value</em>            <em>value</em>      <br>
  1            20-01-12      3                  1            <em>value</em>            <em>value</em>      <br>
  1            20-01-13      3                  2            <em>value</em>            <em>value</em>      <br>
  1            20-01-14      3                  3            <em>value</em>            <em>value</em>      <br>
  2            20-01-15      1                  1            <em>value</em>            <em>value</em>      <br>
  2            20-01-16      1                  2            <em>value</em>            <em>value</em>      <br>
  2            20-01-17      1                  3            <em>value</em>            <em>value</em>      <br></p>
  <p>(where <em>value</em> is the value of the observation for the variable)</p>
  <p>Thank you for your help with this tricky problem !</p>
  <p>Best wishes,
  Eric</p>