Q:

R difftime off by 1 year

I'm trying to calculate the difference-in-years between 2 dates.
time1 <- as.Date(x = "2017-02-14",
                 format = "%Y-%m-%d",
                 origin = "",
                 tz = "")

time2 <- as.Date(x = "1972-02-17",
                 format = "%Y-%m-%d",
                 origin = "",
                 tz = "")

as.integer(x = difftime(time1 = time1,
                        time2 = time2,
                        tz = "",
                        units = "days")) / 365

According to the above code, the difference-in-years is about 45.02466.
A glance at the 2 dates confirms that the difference-in-years is close to, but less than, 45.
The difference-in-years value should begin with 44.
Why is difftime inflating the number of years by 1?

A:

Probably this happens since you divide by  365 days, whereas at least 44/4 = 11 years had a duration of 366 days. You could consider to divide by 365.25, which is a more correct average duration of a year.
Also, you might like to look up the lubridate package to see the interval of how many years have passed between two dates
library(lubridate)
> time1 <- as.Date(x = "2017-02-14",
+                  format = "%Y-%m-%d",
+                  origin = "",
+                  tz = "")
> 
> time2 <- as.Date(x = "1972-02-17",
+                  format = "%Y-%m-%d",
+                  origin = "",
+                  tz = "")
> 
> 
> interval(time2, time1) %/% years(1)
[1] 44

