• Register
0 votes

Problem :

Please have a look at the below date related error :

$ R --vanilla
> as.Date("09 Jan 2019")
Error in charToDate(x) :
character string is not in a standard unambiguous format

But that date is clearly in the correct standard unambiguous format. So why am I facing the above error message?

Worst thing is that, an ambiguous date is apparently accepted and without any warning or error and then read very incorrectly! As shown below:

> as.Date("01/01/2000")
[1] "0001-01-20"
6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

This is the documented behavior. From the ?as.Date:

Format: The character string. If not specified, then it will try '"%Y-%m-%d"' then '"%Y/%m/%d"' on the very first non-'NA' element, and then it will give an error if neither works.

as.Date("09 Jan 2019") gives the error as the format is not in the one of the two listed above. as.Date("01/01/2000") gives an incorrect answer as the date is not in the one of the two formats listed above.

I always take "standard unambiguous" to mean "ISO-8601". If you are receiving above error, then the solution for that is to specify the format of your date in, using the correct formats described in the ?strptime.

Hope my solution helps in resolving your issue.

9 7 4
38,600 points

Related questions

0 votes
1 answer 33 views
Problem: Why I got the error? Error in chartodate(x) : character string is not in a standard unambiguous format.
asked Mar 7 Wafa Abu Yousef 6.1k points
0 votes
2 answers 4 views
Problem: During Java learning I faced this now I need an anser for this. C# string repeat character x times.
asked Mar 24 PkGuy 13.1k points
1 vote
1 answer 18 views
Problem : I use $date = "10.06.2015 09:25:52"; it works well, But When use $date = "13-06-2015 23:45:52"; I got this Error : PHP Fatal error: Call to a member function format() on boolean HELP! I need help understanding this error!
asked Mar 27 Shovo210 14k points
0 votes
1 answer 3 views
Problem: What are my options for resolving this problem? what format is the binary distribution of an android file in
asked Mar 30 rakib1 51.5k points
0 votes
1 answer 34 views
Problem: error in as.date.numeric(value) : 'origin' must be supplied.
asked Feb 16 charles mathews 5.5k points
1 vote
1 answer 7 views
Problem: I’m new in data frame. Here is an example of my data set; Date Time(GMT)Depth Temp Salinity Density Phosphate 24/06/2002 1000 1 33.855 0.01 24/06/2002 1000 45 33.827 0.01 01/07/2002 1000 10 13.26 33.104 24.873 0.06 01/07/2002 1000 30 12.01 ... only have one row per date, I want to do this based on the Depth, I would like to keep the row with the greatest (deepest) depth. Any ideas?
asked Mar 10 Shovo210 14k points
1 vote
1 answer 47 views
I am new to this. I just want to know how to do that?
asked Nov 3, 2020 TeamScript 13.5k points
0 votes
1 answer 46 views
Problem: I am a beginner in the programming world I badly need to execute the query through Java like shown below: public ResultSet execSumStatment2() throws SQLException{ String query = "Select SUM(A) as NCCSeptember from NCC where Datum >= '01-09-2013 00:00:00' and Datum ... the issue is a datatype of my date in my above query which must be Date and everything which I have tried is not working.
asked Jul 25, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 2 views
Problem: I am unable to find out the solution, Please solve it : it is acceptable for dates to have a currency format
asked 5 days ago tuhin1 48.9k points
0 votes
2 answers 3 views
Problem : Any ideas on what I need to do to fix this? Thanks!-it is acceptable for dates to have a currency format?
asked Mar 15 Samiur1 38.4k points