Skip to content

Instantly share code, notes, and snippets.

@mmparker
Created May 22, 2014 21:48
Show Gist options
  • Select an option

  • Save mmparker/33ba6e2af02ae21d9246 to your computer and use it in GitHub Desktop.

Select an option

Save mmparker/33ba6e2af02ae21d9246 to your computer and use it in GitHub Desktop.
Successive pairwise date diffs
library(zoo)
# Some sequence of Dates
x <- as.Date("2014-01-01") + c(0, 1, 2, 5, 10)
data.frame(x,
basediff = c(NA, diff(x)),
mpdiff = c(NA, x[-1] - x[-length(x)])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment