Here is my example. I am reading the following file: sample_data
library(dplyr) txt <- c(\'\"\", \"MDN\", \"Cl_Date\"\', \'\"
According to @hadley here, the solution is to use lubridate instead of relying on base R.
This would be something like:
ts %>% group_by(MDN) %>% arrange(Cl_Date) %>% mutate(as.duration(Cl_Date %--% lag(Cl_Date)))