Guest User

parse time format

a guest
Jan 30th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.10 KB | None | 0 0
  1. library(data.table)
  2. library(lubridate)
  3.  
  4. DT <- fread("
  5.        Time,            Leave,        UniqueBusID,          rid,    qid
  6. 2015-01-01 13:36:50.000,  False, 屯區藝文中心->莒光新城163,    1,      2
  7. 2015-01-01 13:36:56.000,  True , 屯區藝文中心->莒光新城163,    2,      2
  8. 2015-01-01 13:37:28.000,  False, 屯區藝文中心->莒光新城163,    3,      2
  9. 2015-01-01 13:37:38.000,  False, 屯區藝文中心->莒光新城163,    4,      2
  10. 2015-01-01 13:38:43.000,  False, 屯區藝文中心->莒光新城163,    5,      2
  11. 2015-01-01 13:37:53.000,  True , 莒光新城->屯區藝文中心164,    1,      1
  12. 2015-01-01 13:38:19.000,  False, 莒光新城->屯區藝文中心164,    2,      1
  13. 2015-01-01 13:38:38.000,  False, 莒光新城->屯區藝文中心164,    3,      1
  14. 2015-01-01 13:38:58.000,  False, 莒光新城->屯區藝文中心164,    4,      1
  15. 2015-01-01 13:39:10.000,  False, 莒光新城->屯區藝文中心164,    5,      1    ")
  16.  
  17. # method 1
  18. DT[ , Time := fast_strptime(Time, "%Y-%m-%d %H:%M:%OS", lt = FALSE)]
  19. # method 2
  20. DT[ , Time := strptime(Time, "%Y-%m-%d %H:%M:%OS")]
Advertisement
Add Comment
Please, Sign In to add comment