I have this data containing dates from 2000 to 2020:
date[1:5]
# [1] "2000-01-01" "2000-01-02" "2000-01-03" "2000-01-04" "2000-01-05"
str(date)
# Date[1:941], format: 2000-01-01" "2000-01-02" "2000-01-03" "2000-01-04"..
I can do this:
indices <- cut(date, "year")
Then all dates from "2000-01-01" to "2000-12-31" will be mapped to "2000-01-01".
But I want all dates from "1999-12-01" to "2000-11-30" to be mapped to "2000-01-01".
I want the equivalent of cut(date, "year"), but where the year is shifted to start on a month other than January.
How can I do this?