简体   繁体   中英

strptime function in R returns null values

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

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM