Hi! I hope you're enjoying the festive season.
Let's say I have a dataframe with one column (i.e. "Variable 1") containing binary values of 0 or 1. The second column (i.e. "Variable 2") is numeric and has a range of approx. 0-40. I would like to create a new column in this dataframe that is equal to 0 when Variable 1 is equal to 1 and when the value of Variable 2 is greater than what it was in the row directly above the applicable one (if these two conditions are not met, the new column can equal the value of Variable 1). May I ask how I would do this, using either base R or the tidyverse?
Thank you so much!