conditional lagging variables

Hi,

Welcome to the RStudio community!

In order for us to help you with your question, please provide us a minimal reproducible example where you provide a minimal (dummy) dataset and code that can recreate the issue.
A screenshot is not useful as we cannot extract any data from it (unless be manually recreating the whole table).

Once we have a reprex, we can go from there. For help on creating a Reprex, see this guide:

Good luck!
PJ