你如何在 R 中加载微秒精度时间序列? [英] How do you load microsecond precision time series in R?

查看:21
本文介绍了你如何在 R 中加载微秒精度时间序列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从纪元以来的微秒值中加载 POSIXlt 变量.有没有更好的方法来做到这一点:

I need to load POSIXlt variables from microsecond values since the epoch. Is there a better way to do this:

options(digits.secs=6)
mytime=1366039619645990
as.POSIXlt(mytime %/% 1e6, tz="EST", origin="1970-01-01") + (mytime %% 1e6)/1e6
[1] "2013-04-15 10:26:59.64598 EST"

考虑到我要加载数百万条记录,这似乎有点令人费解.

It seems a bit convoluted given I have millions of records to load.

推荐答案

这将摆脱取模和除法:

> mytime=1366039619645991
> mytime.secs = mytime %/% 1e+6
> mytime.usecs = mytime - as.integer(mytime.secs)*1e6
> as.POSIXlt(mytime.secs, tz="", origin="1970-01-01") + mytime.usecs*1e-6+0.0000005
[1] "2013-04-15 11:26:59.645991 EDT"

这篇关于你如何在 R 中加载微秒精度时间序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆