Skip to content

Instantly share code, notes, and snippets.

@EwanDawson
Created May 14, 2013 08:55
Show Gist options
  • Select an option

  • Save EwanDawson/5574613 to your computer and use it in GitHub Desktop.

Select an option

Save EwanDawson/5574613 to your computer and use it in GitHub Desktop.
#R script to get the number of days in a year. Given a vector containing years, returns a vector of the same length with the number of days in each year. Requires #zoo Example: > diy(2000:2004) [1] 366 365 365 365 366
diy <- function(year) {
require(zoo)
as.numeric(as.Date(as.yearmon(year) + 1) - as.Date(as.yearmon(year)))
}
Copy link
Copy Markdown

ghost commented Mar 31, 2015

Thanks for posting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment