I have a vector of integers with 'discountinuities' and I would like to convert in a list of vectors with consecutive values
Example
vec = c(1,2,5,7,8,9,11,12,13,15)
[1] 1 2 5 7 8 9 11 12 13 15
Expected output:
[[1]]
[1] 1 2
[[2]]
[1] 5
[[3]]
[1] 7 8 9
[[4]]
[1] 11 12 13
[[5]]
[1] 15
Is there any simple way to do this?