Reputation: 1033
I am pulling my hair out on this one. I am trying to parse to ymd_hms format using lubridate. I will ultimately merge this two-variable dataframe into a larger one.
The date format in the original csv seems fairly unambiguous (01.01.13 00:00) so I am not sure why I am getting the following error or how to solve it.
Warning message:
All formats failed to parse. No formats found.
I have tried looking online for information on locales but I haven't really had had much success.
This is what I have been running
tariff <- read.csv("tariffs.csv", stringsAsFactors = F, sep = ";")
colnames(tariff) <- c("DateTime", "Tariff")
tariff$DateTime <- lubridate::ymd_hms(tariff$DateTime)
> head(tariff)
DateTime Tariff
1 01.01.13 00:00 Normal
2 01.01.13 00:30 Normal
3 01.01.13 01:00 Normal
4 01.01.13 01:30 Normal
5 01.01.13 02:00 Normal
6 01.01.13 02:30 Normal
> tail(tariff)
DateTime Tariff
17515 31.12.13 21:00 Normal
17516 31.12.13 21:30 Normal
17517 31.12.13 22:00 Normal
17518 31.12.13 22:30 Normal
17519 31.12.13 23:00 Normal
17520 31.12.13 23:30 Normal
> tariff$DateTime <- lubridate::ymd_hms(tariff$DateTime)
Warning message:
All formats failed to parse. No formats found.
Thanks for your help!
Upvotes: 5
Views: 14401
Reputation: 886938
The order of 'y', 'm', 'd' is interchangeble based on the format
of the 'data'. Based on the info showed, 'day' comes first, followed by 2 digit month and 2 digit year. So, it would be
library(lubridate)
dmy_hm(tariff$DateTime)
's' is not included as there was no seconds in the 'DateTime'
Upvotes: 7