【发布时间】:2019-09-19 06:47:21
【问题描述】:
我有一个像下面这样的字符向量,它以 HH:MM:SS.sss 格式保存时间,以便它可以用于数据帧中的时间序列分析
x <- "05:17:55.703"
我想将它转换为没有日期和时区的毫秒时间戳 - 这甚至可能吗?
我尝试了什么 ->
> as.POSIXct("05:17:55.703",format = "%H:%M:%OS")
[1] "2019-09-19 05:17:55 IST"
Issue is that, it doesn't show the milliseconds part and shows the date and timezone which I would like to avoid
> as.POSIXlt("05:17:55.703",format = "%H:%M:%OS")
[1] "2019-09-19 05:17:55 IST"
Issue is that, it doesn't show the milliseconds part and shows the date and timezone which I would like to avoid
> as.POSIXlt("05:17:55.703",format = "%H:%M:%S.%OS")
[1] "2019-09-19 05:17:55 IST"
Issue is that, it doesn't show the milliseconds part and shows the date and timezone which I would like to avoid
> strptime("05:17:55.703", "%H:%M:%OS")
[1] "2019-09-19 05:17:55 IST"
Issue is that, it doesn't show the milliseconds part and shows the date and timezone which I would like to avoid
【问题讨论】:
-
Datetime 对象必须包含日期。但是,我想知道您为什么关心显示的内容。实际值对您来说应该更重要。