[Rd] as.Date.character suggestion

Peter Langfelder peter.langfelder at gmail.com
Wed Aug 20 22:11:53 CEST 2014

The default format="" in as.Date.character is supremely confusing. The
help shows as.Date defined as

## S3 method for class 'character'
     as.Date(x, format = "", ...)

yet the function behaves very differently when format is not specified
and when it is specified to its default:

[1] "2012-01-01"
> as.Date("2012-01-01", format = "")
[1] "2014-08-20"  ### Gives today.

The default setting is never used, because if format is not given,
values "%Y-%m-%d" and "%Y/%m/%d" are tried for it (rather than "").

My suggestion is to leave out the default "" for format in as.Date:

as.Date(x, format, ...)

If this causes a conflict in the S3 dispatching, at least indicate in
the help that the default is never used and the function works
differently if format is specified to its default.



More information about the R-devel mailing list