anytime
can handle it with an additional format entry (as d.m.Y can be confused with m.d.Y we do not add it by default, by entering it you make a more conscious choice).
> times <- c("24.02.2012 22:00", "24.02.2012 22:15:00", "24.02.2012 22:30:00",
+ "24.02.2012 22:45:00", "24.02.2012 23:00")
> library(anytime)
> addFormats("%d.%m.%Y %H:%M:%S")
> anytime(times)
[1] "2012-02-24 22:00:00 CST" "2012-02-24 22:15:00 CST" "2012-02-24 22:30:00 CST"
+ "2012-02-24 22:45:00 CST" "2012-02-24 23:00:00 CST"
>
So you could overwrite your column, or add a new ones, via
> library(anytime)
> addFormats("%d.%m.%Y %H:%M:%S")
> X1$parsed <- anytime(X1$raw_dates)
(assuming you have the data in X
in that column) after adding the format as shown. Formats are added to the vector of known
formats only for the current session.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…