title: R - manipulate last rows depending on group and previous elements
body: <p>Im fairly new to R and struggling to find a solution for the following problem:
  I have a tibble consisting of 3 columns. First column describes ids of stocks (e.g. ID1,ID2..), the second the Date of observation and third the corresponding return. (ID | Date | Return )</p>
  <p>For tidying my dataset I need to delete all zero returns starting from end of sample period until i reach the first non zero return.<br />
  The following picture further visualises my issue.</p>
  <p><a href="https://i.stack.imgur.com/I5gVr.jpg" rel="nofollow noreferrer">DatasetExample</a></p>
  <p>In case of the example Dataset depicted above, I need to delete the yellow coloured elements.</p>
  <p>Hence, one needs to first group by ID and second iterate over the table from bottom to top until reaching a non zero return.
  I already found a way by converting the tibble into a matrix and then looping over each element but this apporach is rather naive and does not perform well on large datasets (+2 mio. observations), which is exactly my case.
  Is there any more effcient way to achieve this aim? Solutions using dplyr would be highly appreciated.
  Thanks in advance.</p>