Why R package lubridate can't parse vector with multiple formats?
问题 I'm using package lubridate to parse a vector of heterogeneously-formatted dates and convert them to string, like this: parse_date_time(c('12/17/1996 04:00:00 PM','4/18/1950 0130'), c('%m/%d/%Y %I:%M:%S %p','%m/%d/%Y %H%M')) This is the result: [1] NA NA Warning message: All formats failed to parse. No formats found. If I remove the %p in the 1st format string, it incorrectly parses the 1st date string, and still doesn't parse the 2nd, like so: [1] "1996-12-17 04:00:00 UTC" NA Warning message