Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Ways to resolve the error - error in chartodate(x) : character string is not in a standard unambiguous format
Next
Answered
Damien Wilson
  • 27
Damien Wilson
Asked: May 12, 20222022-05-12T08:03:36+00:00 2022-05-12T08:03:36+00:00In: r

Ways to resolve the error – error in chartodate(x) : character string is not in a standard unambiguous format

  • 27

. Advertisement .

..3..

. Advertisement .

..4..

I am tired of fixing the problem: error in chartodate(x) : character string is not in a standard unambiguous format in the r; even if I get the reference from another forum, it still returns an error:

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

To identity the problem, I will show you the detail here:

> as.Date("01/01/2000")
 [1] "0001-01-20"
> sessionInfo()
 R version 2.15.2 (2012-10-26)
 Platform: x86_64-w64-mingw32/x64 (64-bit)
 
 locale:
 [1] LC_COLLATE=English_United Kingdom.1252
 [2] LC_CTYPE=English_United Kingdom.1252
 [3] LC_MONETARY=English_United Kingdom.1252
 [4] LC_NUMERIC=C
 [5] LC_TIME=English_United Kingdom.1252
 
 attached base packages:
 [1] stats graphics grDevices utils datasets methods base

How do I do that? Could you support me in improving this problem?

error in chartodate(x)
  • 2 2 Answers
  • 317 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    lyytutoria Expert
    2022-05-30T13:47:59+00:00Added an answer on May 30, 2022 at 1:47 pm

    The cause: This behavior is documented. ?as.Date:

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

    as.Date("01 Jan 2000") returns an error as the format of as.Date("01 Jan 2000") is not one of the ones listed above. as.Date("01/01/2000") returns an error because the date is not in one of these formats.

    Solution: I interpret “standard unambiguous” to refer to “ISO-8601” (even if as.Date isn’t as strict as ISO-8601, since “%m/%d/%Y” isn’t ISO-8601).

    This error can be fixed by specifying the date format you received. Use the Details section of ?strptime to do this. You must ensure that both the order and any separators match the format of your in string. You should also be careful if your data contains day/month names or abbreviations. The conversion will depend upon your location

    • 12
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Julia Marchal
    2022-05-25T19:34:48+00:00Added an answer on May 25, 2022 at 7:34 pm

    In other words, is there a better solution than needing to specify the format?

    Yes, it is (ie in late 2016), thanks anytime::anydate from anytime.

    For some examples, see the following:

    R> anydate(c("01 Jan 2000", "01/01/2000", "2015/10/10"))
    [1] "2000-01-01" "2000-01-01" "2015-10-10"
    R> 

    These are unambiguous, and should work as you have already stated. They do, thanks to anydate(). Without a format.

    • 22
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.