9

I have some 13-digit numbers in an XLS file and I use Excel to generate the CSV file because I need to process it in R.

Then when R read the CSV file, it cannot recognize the big numbers. For example, 1329100082670 would appear like 1.329E+12 in R and lost its precision.

I've tried to format the big numbers as text in Excel and then save it as CSV but that didn't work!

Thanks in advance!

Mario Boss
  • 1,784
  • 3
  • 20
  • 43
Natalia
  • 369
  • 3
  • 15
  • 1
    Possible duplicate of [How do I read large numbers precisely in R and perform arithmetic on them?](http://stackoverflow.com/questions/24358199/how-do-i-read-large-numbers-precisely-in-r-and-perform-arithmetic-on-them) – shea Feb 05 '16 at 22:17

1 Answers1

10

The numbers are probably all there, by default R doesn't aways show them. See

> a<-1329100082670
> a
[1] 1.3291e+12
> dput(a)
1329100082670

The dput() shows all the digits are retained even if they display on screen in scientific notation. You can discourage R from using scientific notation by setting the scipen option. Something like

options(scipen=999)

will turn off most scientific notation. But really, what it looks like on screen shouldn't be too important to you hopefully.

MrFlick
  • 195,160
  • 17
  • 277
  • 295