I want to delete data with gaps between the max and min time period corresponding to an individual id. Each Id can start and end in any time period, that is fine. I just want to grab ids that do not have missing time within the max and min time.
library(data.table)
set.seed(5)
data<-data.table(y=rnorm(100))
data[sample(1:100, 40),]<-NA
id = rep(1:10, each = 10)
time = seq(1,10)
data2<-data.frame(id,time)
data2$row<-1:nrow(data2)
data2a<-subset(data2,row<55|row>61 )
data3<-data2a[-sample(nrow(data2a), 5),]
data.table(data3)
count(data3$id)
Here is a good example. Group 1 should be deleted, but not 6 for example.