dplyr::case_when() + lag to iterate through a column

What do you mean by test_date[2] ?
As I understand it, this would be the value of the column test_date for the second observation.
This would imply that whatever the calculation in the case_when clause the result period for all observations would be the same.
How could then the value for the first observation be NA ?

Please indicate exactly in words how you would like to calculate period.
And please provide you input as described e.g. in

1 Like