且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从R中的日期时间提取日期的最快方法

更新时间:2023-02-18 10:24:38

请注意,在日期之后, as.Date 将忽略垃圾,因此在我使用的不是特别快的笔记本电脑上,此操作不到10秒:

Note that as.Date will ignore junk after the date so this takes less than 10 seconds on my not particularly fast laptop:

xx <- rep("10/17/2017 12:00:00 AM", 5000000) # test input
system.time(as.Date(xx, "%m/%d/%Y"))
## user  system elapsed 
## 9.57    0.20    9.82