powered by
Date
Convert a Date vector to a numeric vector (either continuous or truncated).
year(date, trunc = FALSE, year.length = 365.24)
numeric vector
Date vector
logical for whether to truncate the date to a whole year or consider the date as a double (default).
assumed length of a year
For the double calculation, we use (truncated year of Date) + (date - 1 Jan of Year)/year.length.
c(year(as.Date("2001-07-01")),year(as.Date("2001-01-01"),trunc=TRUE))
Run the code above in your browser using DataLab