# date coercion
as_year(Sys.Date())
# POSIXt coercion
as_year(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"))
# Character coercion
as_year("2019-05-03")
# direct construction
year(2011:2020)
Run the code above in your browser using DataLab