Reputation: 11
Strptime function in R returns null values. I have a column in my dataset which has time in the foll format "2000" "1830" and so on.....
I am trying to give a time format to a column and get the date and time in the below specified format "%Y-%m-%d %H:%M:%S"
data$date <- strptime(data$date, '%Y-%m-%d %H:%M')
when I run the code I am getting NA's
Upvotes: 1
Views: 323
Reputation: 6132
It seems like you only have a time, not a date, is that correct? Also, there is no :
between the hour and minutes in your data, but you did specify it in the format. Does this help?
strptime("2000", format = "%H%M")
strptime("1830", format = "%H%M")
Upvotes: 2