【发布时间】:2012-08-28 14:52:56
【问题描述】:
我正在做一个产生自动记录数据的实验。该软件会生成格式为41149.014850 的时间戳。我想将此十进制时间戳转换为28.08.2012 00:21:23。我怎样才能最优雅地在 R 中做到这一点?
我尝试使用函数 strsplit 以及指定原点的函数 as.Date 以及 times 函数。但无济于事。我在将时间戳分成两个数字时遇到问题,我可以使用函数 as.Date 和 times 访问它们。
这是一些演示代码:
myDatetime <- c(41149.004641, # 28.08.2012 00:06:41
41149.009745, # 28.08.2012 00:14:02
41149.014850, # 28.08.2012 00:21:23
41149.019954) # 28.08.2012 00:28:44
## not working out for me
Dat.char <- as.character(myDatetime)
date.split <- strsplit(Dat.char, split = "\\.")
## how to proceed from here, if it is a good way at all
【问题讨论】: