I have a dataframe, df, which has factor variable for date in the following format:
2015-12-15 10:00:00
2015-12-19 12:00:00
2015-12-20 20:00:00
It is hourly data. The problem arises when looking at midnight, 00:00:00, because it doesn't appear the hour. It just says:
21/12/2015
So as you see, it only says the day but it lacks the hour. So I use strptime to convert to a date format using:
df$date <- strptime(df$date,"%d/%m/%Y %H:%M")
It all works fine for all the hours and days except for any day at midnight, 00:00:00, which returns:
NA
I'd really appreciate some help as I've been looking at previous posts in StackOverflow and other forums but I havent' managed to figure out the solution for this specific problem yet.
"%d/%m/%Y %H:%M"
shouldn't work for any of them. that says "day/month/year hour:min", not "year-month-day hour:min:sec" Be sure to actually provide a reproducible example. – Kaikaiaformat(dates,"%Y/%m/%d %H:%M")
– Wordless