I have two dates
begin <- as.Date("2007-05-20")
end <- as.Date("2010-06-13")
How can I count the days per year?
The output should maybe look like this
year days
2007 226
2008 366
2009 365
2010 164
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Let’s first create a proper date sequence:
We then create a helper function which, given a date, returns its year:
After that, we just call
table()on what the helper returns from the date sequence: