Thanks, I read the thread and think it is a little different. In my case, I'd like to find out all four columns of the longest time period with continuous data. I think it is better to fill the missing dates in my dataset, and then to find out the longest continuous time period?
Updates:
In one of my datasets, I filled the missing dates with NA values for the Data column, and followed the rle function as in the post you mentioned. The difference is that I did not use the desired length as a screening criterion. Then I got the dfExtracted and runs results here, but I don't know what they represent. For example, does the dfStartIndex represent the 70th row in the original dataset, with 296 rows followed, or does it represent the 70th row in the runs dataframe? I want to find out the longest consecutive days with no NA value, and plot the time series on a figure. Thanks very much.
> dfExtracted
dfStartIndex dfSeqLength
2 70 296
4 731 3652
> runs
Run Length Encoding
lengths: int [1:4] 70 296 365 3652
values : logi [1:4] FALSE TRUE FALSE TRUE
The row number starts from 0?