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!
You can disable scientific notation in the entire R session by using the scipen option. Global options of your R workspace. Use options(scipen = n) to display numbers in scientific format or fixed. Positive values bias towards fixed and negative towards scientific notation.
If you want to avoid scientific notation for a given number or a series of numbers, you can use the format() function by passing scientific = FALSE as an argument.
Method 1: Using scipen option In order to eliminate the exponential notation of the integer, we can use the global setting using options() method, by setting the scipen argument, that is options(scipen = n).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With