Peanica
Peanica

Reputation: 113

fread() reads big number as 4.076092e-309

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?

Upvotes: 1

Views: 425

Answers (1)

Spacedman
Spacedman

Reputation: 94182

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...

Upvotes: 4

Related Questions