These functions allow the extraction of particular date components
from messy dates, such as the year()
, month()
, and day()
.
precision()
allows for the identification of the greatest level of
precision in (currently) the first element of each date.
Value
year()
, month()
, and day()
extraction return the integer
for the requested date component.
precision()
returns the level of greatest precision for each date.
Precision
Date precision is measured relative to the day in \(1/days(x)\). That is, a date measured to the day will return a precision score of 1, a date measured to the month will return a precision score of between \(1/28\) and \(1/31\), and annual measures will have a precision of between \(1/365\) and \(1/366\).
Examples
year(as_messydate(c("2012-02-03","2012","2012-02")))
#> [1] 2012 2012 2012
month(as_messydate(c("2012-02-03","2012","2012-02")))
#> [1] 2 NA 2
day(as_messydate(c("2012-02-03","2012","2012-02")))
#> [1] 3 NA NA
precision(as_messydate(c("2012-02-03","2012","2012-02")))
#> [1] 1.00000000 0.00273224 0.03448276