Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R dates "origin" must be supplied

Tags:

date

r

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?

like image 607
Nate Avatar asked May 08 '10 03:05

Nate


People also ask

What is the origin of the dates in R?

When R looks at dates as integers, its origin is January 1, 1970.

Is Na error in as date numeric value origin must be supplied?

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.

How are dates handled in R?

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.


Video Answer


1 Answers

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.

like image 160
Dirk Eddelbuettel Avatar answered Sep 29 '22 08:09

Dirk Eddelbuettel