![](/img/trans.png)
[英]integer64 class in r data.table, sum() and by=.()
[英]Convert numeric (integer64 class) UNIX timestamp to date time class
到處都有類似的問答,但沒有一個能幫助我克服以下錯誤(我正在嘗試將Unix時間轉換為日期時間格式):
> cur196$time
integer64
[1] 1566204590000 1566204585000 1566204580000 1566204570000 1566204560000 1566204550000 1566204531000 1566204525000 1566204521000 1566204501000
[11] 1566204495000 1566204491000 1566204481000 1566204464000 1566204461000 1566204451000 1566204441000 1566204434000 1566204431000 1566204420000
[21] ...
> cur196$time <- as.POSIXct(cur196$time, origin = "1970-01-01", tz = "GMT")
Error in as.POSIXct.default(cur196$time, origin = "1970-01-01", tz = "GMT") :
do not know how to convert 'cur196$time' to class “POSIXct”
編輯:
> dput(head(cur196$time))
structure(c(7.73807882277875e-312, 7.73807879807547e-312, 7.73807877337218e-312,
7.73807872396562e-312, 7.73807867455905e-312, 7.73807862515249e-312
), class = "integer64")
編輯2:
@ zx8754非常感謝您更改標題,並指出了實際的問題-Unix時間戳以毫秒為單位,因此轉換時就很大。
問題是,你的數據有類integer64
從bit64
包。 您需要在加載bit64
軟件包時使用as.integer()
將其轉換為普通整數。 然后,您可以在其上使用as.POSIXct()
。
但是可能您應該首先研究如何導入數據以及為什么以這種方式保存數據。 是否需要為64位整數?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.