更新时间:2022-10-16 11:58:07
正如其他人指出的那样,您不能表示那么大的整数.但是R并没有将这些值读取为整数,而是将其读取为双精度数字.
As others have noted, you can't represent integers that large. But R isn't reading those values into integers, it's reading them into double precision numerics.
双精度只能将数字精确地表示为约16位,这就是为什么您看到数字在16位后四舍五入的原因.参见 gmp , int64 软件包,以寻求潜在的解决方案.尽管我看不到其中任何一个读取文件的功能,但也许您可以通过查看它们的来源来制作一些东西.
Double precision can only represent numbers to ~16 places accurately, which is why you see your numbers rounded after 16 places. See the gmp, Rmpfr, and int64 packages for potential solutions. Though I don't see a function to read from a file in any of them, maybe you could cook something up by looking at their sources.
更新:
将文件放入int64
对象的方法如下:
UPDATE:
Here's how you can get your file into an int64
object:
# This assumes your numbers are the only column in the file
# Read them in however, just ensure they're read in as character
a <- scan("temp.csv", what="")
ia <- as.int64(a)