title: R function which transforms data adds new column depending on counted grouped rows
body: <p>I am new in R, so maybe anyone could help me.
  I have dataset like this</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Date</th>
  <th>Revenue</th>
  <th>Sales</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>2022.01.01</td>
  <td>10</td>
  <td>20</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2022.02.01</td>
  <td>11</td>
  <td>21</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2022.03.01</td>
  <td>12</td>
  <td>22</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2022.01.01</td>
  <td>13</td>
  <td>33</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2022.02.01</td>
  <td>14</td>
  <td>41</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2022.03.01</td>
  <td>15</td>
  <td>51</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2022.04.01</td>
  <td>16</td>
  <td>61</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need to transform this dataset, with group_by(ID). Also is important how much rows there is by group.<br />
  My transformed data must look like that:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Revenue4</th>
  <th>Revenue3</th>
  <th>Revenue2</th>
  <th>Revenue1</th>
  <th>Sales4</th>
  <th>Sales3</th>
  <th>Sales2</th>
  <th>Sales1</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>-</td>
  <td>12</td>
  <td>11</td>
  <td>10</td>
  <td>-</td>
  <td>22</td>
  <td>21</td>
  <td>20</td>
  </tr>
  <tr>
  <td>2</td>
  <td>16</td>
  <td>15</td>
  <td>14</td>
  <td>13</td>
  <td>61</td>
  <td>51</td>
  <td>41</td>
  <td>33</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need to do this by some function, because I have a lot of rows with different ID's and about 40 columns.</p>
  <p>Thank You!</p>