I\'m trying to calculate the time difference between two timestamps in two adjacent rows using the dplyr package. Here\'s the code:
tidy_ex <- function ()
Thanks to Victorp for the suggestion. I changed the mutate line to:
mutate(diff = c(difftime(tail(timestamp, -1), head(timestamp, -1)),0))
(The 0 I placed at the end so the difference calculation would start in the first row).