R Error in as.Date.numeric(X) : ‘origin’ must be supplied (2 Examples)

 

This tutorial explains how to deal with the error message in as.Date.numeric(X) : ‘origin’ must be supplied in R.

Table of contents:

Here’s how to do it.

 

Example 1: Reproduce the Error in as.Date.numeric: ‘origin’ must be supplied

This example explains how to replicate the R programming error in as.Date.numeric(X) : ‘origin’ must be supplied.

Let’s assume that we want to create a data object with the class Date using the as.Date function in R:

as.Date(10101)                           # Trying to apply as.Date function
# Error in as.Date.numeric(10101) : 'origin' must be supplied

The previous R code returns the error message as.Date.numeric(X) : ‘origin’ must be supplied to the RStudio console.

The reason is that we have not specified the origin argument within the as.Date function and, hence, the as.Date function doesn’t know how to convert the numeric value 10101 that we have inserted within the function.

Let’s solve this problem…

 

Example 2: Fix the Error in as.Date.numeric: ‘origin’ must be supplied

Example 2 explains how to handle the error in as.Date.numeric(X) : ‘origin’ must be supplied by specifying the origin argument within the as.Date function:

as.Date(10101, origin = "2000-01-01")    # Specifying origin in as.Date function
# "2027-08-28"

The output of the previous R syntax is a Date – great!

 

Video & Further Resources

Do you need more information on the contents of this tutorial? Then I can recommend to watch the following video of my YouTube channel. In the video, I’m illustrating the R syntax of this tutorial:

 

The YouTube video will be added soon.

 

Besides the video, you may want to read the related tutorials on my homepage.

 

In this R programming tutorial you learned how to handle the error in as.Date.numeric(X) : ‘origin’ must be supplied. Please let me know in the comments section below, in case you have further comments and/or questions.

 

Subscribe to my free statistics newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu
Top