I have a time series dataset with around 120,000 rows, which I am storing as a data frame. Most of the data is at 15 minute interval, but there is some monthly data also. I want to keep only the 15 minute data and eliminate the data at monthly interval. So I am calculating the difference between consecutive timestamp and then eliminating everything not equal to 15 minutes (900 seconds). My timestamp column name is 'datetime'. I am using the following to calculate the time interval-
site_data[1:nrow(site_data)-1,"Interval"] <- as.numeric(difftime(site_data[2:nrow(site_data),"DateTime"],
site_data[1:nrow(site_data)-1,"DateTime"]))
But this code is taking too long to run. Is there a faster alternative to difftime? The timestamp column is POSIXct type date-time. Thank you.