I have a vector 'a' that is a numerical vector of row indices. I'd like to get these rows as well as the next 20 rows next to them out of a dataframe called 'data'. Is there a way to do this?
I've already tried:
data2 <- data[a:a+20,]
but without success.
If a <- c(1, 21, 42)
I'd like to extract rows 1:20, 21:41, and 42:62 from 'data' and store them in another object.