I am stuck with question. how to join consecutive duplicate odd list and remove all but first list. I have got how to sum consecutive duplicate rows and remove all but first row (link: R sum consecutive duplicate odd rows and remove all but first). But this project, i would like to join the consecutive duplicate odd list but not all of the consecutive duplicate list.
data.table or dplyr will be fine
for example:
ia<-c(1,1,2,2,1,1,1,1)
time <- list(c(23,43),
c(24,54,32),
c(23,43,232),
c(24,54,32),
c(23,43,2),
c(24,54,32),
c(24,54,32),
c(24,54,32)
)
to
res_time <- list(c(23,43,24,54,32), # 1+1
c(23,43,232), # 2
c(24,54,32), # 2
c(23,43,2,24,54,32,24,54,32,24,54,32) # 1+1+1+1
)
Thanks!