我正试图解析这样的日期时间。14.08.2014 00:00:01.202
我想得到以下的表格:
作为R的新手,我了解有一些处理时间的包。现在,根据我的研究和技术水平,我正在研究的是 lubridate
包来尝试完成这些任务。我遇到了困难,因为毫秒的问题(我想)。
谁能给我一个完成这些任务所需要的代码的例子?
首先转换为 POSIXct
种类
MyDate <- as.POSIXct("14.08.2014 00:00:01.202", format = "%d.%m.%Y %H:%M:%S")
MyDate
## [1] "2014-08-14 00:00:01 IDT"
平日
format(as.Date(MyDate), "%w") # Weekday as decimal number (0–6, Sunday is 0).
## [1] "3"
或
format(as.Date(MyDate), "%u") # Weekday as a decimal number (1–7, Monday is 1).
## [1] "3"
增加分钟
MyDate + 60
## [1] "2014-08-14 00:01:01 IDT"
加小时
MyDate + 3600
## [1] "2014-08-14 01:00:01 IDT"