diff_years | R Documentation |
Calculate date difference in years, taking into account leap years.
diff_years(start, stop)
start |
starting date of time interval |
stop |
ending date of time interval |
Since the number of days in a year changes depending on whether said year is a leap year, dividing a period of time by estimates such as 365.25, 365.241, 365.24442 will be slightly biased. The correct way to calculate a length of period in years is to take into account which years are leap years and divide by 365 or 366 as needed.
A numeric value representing the date difference in years
start <- as.Date("2009-03-08")
stop <- as.Date("2009-08-09")
diff_years(start, stop)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.