extract vector elements of unknown range
Dear all, I have two vectors ? x <- c(1:20) ? y <- c(1,5,10,14) Now I would like to extract ? x[ (y[n] + 2):(y[n+1] - 1) ] for all elements except last one in y. This means I want to have ??x[ c( (y[1]+2):(y[2]-1), (y[2]+2):(y[3]-1), (y[3]+2):(y[4]-1) ) ] How is this possible if y is a vector of unknown length? Best regards Joseph