As said in the title, I have a data.frame like below,

```
df<-data.frame('id'=c('1','1','1','1','1','1','1'),'time'=c('1998','2000','2001','2002','2003','2004','2007'))
df
  id time
1  1 1998
2  1 2000
3  1 2001
4  1 2002
5  1 2003
6  1 2004
7  1 2007

```

there are some others cases with shorter or longer time window than this,just for illustration's sake.

I want to do two things about this data set, first, find all those `id` that have **at least** five consecutive observations here, this can be done by following solutions [here](https://stackoverflow.com/questions/35302831/aggregate-by-consecutive-values-and-group?rq=1). Second, I want to keep only those observations in the **at least five consecutive row** of `id` selected by first step. The ideal result would be :

```
df
  id time
1  1 2000
2  1 2001
3  1 2002
4  1 2003
5  1 2004

```

I could write a complex function using for loop and `diff` function, but this may be very time consuming both in writing the function and getting the result if I have a bigger data set with lots if `id`. But this is not seems like R and I do believe there should be a one or two line solution.

Anyone know how to achieve this? your time and knowledge would be deeply appreciated. Thanks in advance.