Closed tcwilkinson closed 4 years ago
Thanks for your comments and the examples, but AsDate
is actually doing what its supposed to. The function tries to use information from other values in the the vector to guess the format of the dates. For example, this will give you warnings about ambiguous date formats: AsDate(c("01-01-2010"))
, but not AsDate(c("01-01-2010", "13-01-2010"))
As you say, one alternative is to vectorize it. You might also want to look at the anytime
package. We had some trouble with it when the format is ambiguous (i.e. could be US or international format) but it is very flexible.
This happens when the format of the input vector is not identical: Reproducible examples...
These work:
This fails:
Obviously vectorising AsDate() is an option, as workaround, but it's an ugly clunk:
Would be great if this could be handled internally to
AsDate()
.