问题
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