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:
Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.
If you accept this notice, your choice will be saved and the page will refresh.
Besides the video, you may want to read the related tutorials on my homepage.
- Convert Date to Numeric Time Object
- Format Number as Percentage in R
- Fixing Error & Warning Messages in R
- All R Programming Examples
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.