I have a variable x
in my dataset (Jan 2018 - June 2021):
date | specific_date | x
2018-01-31 | 2019-10-31 | 0
...
2019-08-31 | 2019-10-31 | 0
2019-09-30 | 2019-10-31 | 0
2019-10-31 | 2019-10-31 | 1
2019-11-30 | 2019-10-31 | NA
2019-12-31 | 2019-10-31 | NA
...
2021-06-30 | 2019-10-31 | NA
I would like to move everything up a month in x
, like this (1 goes from date
=2019-10-31 to date
=2019-09-30, and so on):
date | specific_date | variable
2018-01-31 | 2019-10-31 | 0
...
2019-08-31 | 2019-10-31 | 0
2019-09-30 | 2019-10-31 | 1
2019-10-31 | 2019-10-31 | NA
2019-11-30 | 2019-10-31 | NA
2019-12-31 | 2019-10-31 | NA
...
2021-06-30 | 2019-10-31 | NA
Any ideas on how to do this?