I am thinking of getting max of (N-1) rows by group in R (but not including the current row). Not sure how should I start with since each group has dynamics number of rows. For example:

[![Example of what I want](https://i.stack.imgur.com/BLqWK.png)](https://i.stack.imgur.com/BLqWK.png)

Thanks =)