I would like to get a sequence between the elements in the vector. Here is a reproducible example.
vec <- c( 'a', letters[2:7], 'a', letters[9:14], 'a', letters[16:21] )
ind_a <- which( grepl( 'a', vec ))
ind_a <- c( ind_a, length(vec)+1 )
ind_a
Now how to calculate the sequence between the elements ind_a. For example, seq(from = 2, to = 7, by = 1)and the same for others.
Preferably, I would like to know any function in the R database for this task.
Expected Result
source
share