My code:
axis.Date(1,sites$date, origin="1970-01-01")
Error:
Error in as.Date.numeric(x) : 'origin' must be supplied
Why is it asking me for the origin when I supplied it in the above code?
When R looks at dates as integers, its origin is January 1, 1970.
The “Error in as. date. numeric(value) : 'origin' must be supplied” error message occurs when converting a numeric value into a date. It is a result of omitting a component from the function.
R provides several options for dealing with date and date/time data. The builtin as. Date function handles dates (without times); the contributed library chron handles dates and times, but does not control for time zones; and the POSIXct and POSIXlt classes allow for dates and times with control for time zones.
I suspect you meant:
axis.Date(1, as.Date(sites$date, origin = "1970-01-01"))
as the 'x' argument to as.Date()
has to be of type Date
.
As an aside, this would have been appropriate as a follow-up or edit of your previous question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With