fread() reads big number as 4.076092e-309

给你一囗甜甜゛ 提交于 2019-12-31 04:38:32

问题


The original numbers are integers from 825010211307012 to 825010304926185. fread() turns all those numbers to 4.076092e-309.

read.table works normally, but I need to read large data so I can't use it.

How can I correct this error?


回答1:


If you install the bit64 package then fread will use it to read these large integers:

before:

> fread("./bignums.txt")
              V1
1: 4.076092e-309
2: 4.076092e-309

Do the magic:

> install.packages("bit64")

Then:

> fread("./bignums.txt")
                V1
1: 825010211307012
2: 825010304926185

fread has read them into 64 bit integers:

> fread("./bignums.txt")$V1
integer64
[1] 825010211307012 825010304926185

I don't know why fread misreads them when bit64 isn't available. I'd at least expect a warning...



来源:https://stackoverflow.com/questions/45015794/fread-reads-big-number-as-4-076092e-309

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!