保留大数 [英] Preserving large numbers

查看:19
本文介绍了保留大数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取第一列中有条形码的 CSV 文件,但是当 R 将其放入 data.frame 时,它​​会将 1665535004661 转换为 1.67E+12.

I am trying to read a CSV file that has barcodes in the first column, but when R gets it into a data.frame, it converts 1665535004661 to 1.67E+12.

有没有办法以整数格式保存这个数字?我尝试分配一个 "double" 类,但这不起作用,也没有分配一个 "character" 类.一旦它采用 1.67E+12 格式,任何将其转换回整数的尝试都会返回 167000000000.

Is there a way to preserve this number in an integer format? I tried assigning a class of "double", but that didn’t work, nor did assigning a class of "character". Once it is in the 1.67E+12 format any attempt to convert it back to an integer returns 167000000000.

推荐答案

它不是1.67E+12 格式",它只是不会完全使用默认值进行打印.R 读得很好,整个数字都在那里.

It's not in a "1.67E+12 format", it just won't print entirely using the defaults. R is reading it in just fine and the whole number is there.

x <- 1665535004661
> x
[1] 1.665535e+12
> print(x, digits = 16)
[1] 1665535004661

看,数字一直在那里.除非您有大量数字,否则它们不会丢失.对您带来的内容进行排序会正常工作,您可以使用数字选项显式调用 print() 来查看您的 data.frame,而不是通过键入名称来隐式调用.

See, the numbers were there all along. They don't get lost unless you have a really large number of digits. Sorting on what you brought in will work fine and you can just explicitly call print() with the digits option to see your data.frame instead of implicitly by typing the name.

这篇关于保留大数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆