Created
May 14, 2013 08:55
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diy <- function(year) { | |
| require(zoo) | |
| as.numeric(as.Date(as.yearmon(year) + 1) - as.Date(as.yearmon(year))) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for posting this!