I have a raster stack containing 84 layers each of which corresponds to 1 month of rainfall from November 1999 to October 2006. I have named the layers in my raster stack 199911 to 200610 i.e. year followed by month. I also have a spatial points dataframe where each row has a date in identical format.
I want to extract from the raster stack the sum of all the rainfall between the date of a row and the previous October at that row's spatial location. So if a row's date was 20006 (June 2000) it would sum all the rainfall at that row's location between 199910 (October 1999) and 20006. As I have lots of data I want to automate this process.
I've tried to get this to work but with no joy. Does anyone have any tips?