. Advertisement .
. Advertisement .
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")  "0001-01-20"
> sessionInfo() R version 2.15.2 (2012-10-26) Platform: x86_64-w64-mingw32/x64 (64-bit) locale:  LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252  LC_MONETARY=English_United Kingdom.1252  LC_NUMERIC=C  LC_TIME=English_United Kingdom.1252 attached base packages:  stats graphics grDevices utils datasets methods base
How do I do that? Could you support me in improving this problem?
The cause: This behavior is documented.
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.Dateisn’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
?strptimeto 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
Yes, it is (ie in late 2016), thanks
For some examples, see the following:
These are unambiguous, and should work as you have already stated. They do, thanks to
anydate(). Without a format.