Converts an array of Date (or coercible to Date) values to DOY (Day Of the Year) values. Simple wrapper around strftime(date, format = "%j").

datetodoy(dates, abort = FALSE)

Arguments

dates

array of dates to be converted. Class must be Date or character parsable to Date using as.Date (format "yyyy-mm-dd").

abort

logical If TRUE, the function aborts if even just one of the dates fails converting (i.e., because one date is NA). If FALSE, a warning is issued instead, Default: FALSE

Examples

# Convert a date to a doy datetodoy(as.Date("2000-04-01"))
#> [1] 92