I have a large raster stack that I need to subset by somewhat irregular time spans. I'd like to do something like this:
rstack[[c(1:3, 4:8, 9:15)]]
But there are 30 sequences like the ones above that I need to subset by, and I'd rather not type them all in manually.
I'm wondering if I can create a vector object, something like this:
vec <- c(1:3, 4:8, 9:15) rstack[[vec]]
But based off of a data frame where I have the start, end values for the sequences to automate the process?:
df <- tibble( start = c(1, 4, 9), end = c(3, 8, 15) ) # A tibble: 3 x 2 start end <dbl> <dbl> 1 1 3 2 4 8 3 9 15