长的数字作为字符串 [英] Long Numbers As A Character String
问题描述
作为我的数据集的一部分,其中一列是一系列24位数字。
示例:
bigonumber< - 429382748394831049284934
它使用 data.table :: fread
或 read.csv
,它以指数格式显示为数字:4.293827e + 23)。
options(digits = ...)
as。字符(bigonumber)
我得到的是4.29382748394831e + 23
有没有办法得到 bigonumber
转换为字符串并显示所有的数字作为字符?我不需要做任何数学,但我需要搜索它,并 dplyr
加入它。
我需要在导入后输入,因为列号每月都有所不同。
在完美的世界中,我的上游数据提供程序将使用哈希,而不是长数和每月保持不变的静态列数,但我不能指定给他们。)
可以在fread或read.csv语句中指定colClasses。
bignums
429382748394831049284934
429382748394831049284935
429382748394831049284936
429382748394831049284937
429382748394831049284938
429382748394831049284939
bignums< .csv(〜/ Desktop / bignums.txt,sep =,colClasses ='character')
As part of my dataset, one of the columns is a series of 24-digit numbers.
Example:
bigonumber <- 429382748394831049284934
When I import it using either data.table::fread
or read.csv
, it shows up as numeric in exponential format (EG: 4.293827e+23).
options(digits=...)
won't work since the number is longer than 22 digits.
When I do
as.character(bigonumber)
what I get is "4.29382748394831e+23"
Is there a way to get bigonumber
converted to a character string and show all of the digits as characters? I don't need to do any math on it, but I do need to search against it and do dplyr
joins on it.
I need to this after import, since the column number varies from month to month.
(Yes, in the perfect world, my upstream data provider would use a hash instead of a long number and a static number of columns that stay the same every month, but I don't get to dictate that to them.)
You can specify colClasses on your fread or read.csv statement.
bignums
429382748394831049284934
429382748394831049284935
429382748394831049284936
429382748394831049284937
429382748394831049284938
429382748394831049284939
bignums <- read.csv("~/Desktop/bignums.txt", sep="", colClasses = 'character')
这篇关于长的数字作为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!