Scientific Notation in R

I have an identifier variable with 20 digits. After I read the data in R, it will change to scientific notation, and then if I write the same identifier to the csv file, the ID value will change.

For example, when you run the code below, the x value should be specified as " 12345678912345678912 ", but it will print " 12345678912345679872 ":

The code:

options(scipen=999)

x <- 12345678912345678912

print (x)

Conclusion:

[1] 12345678912345679872

My questions:

1) Why is this happening?

2) How to fix this problem?

I know this has to do with storing data types in R, but still I think there must be some way to deal with this problem. I hope I understand this question clearly.

I do not know if this question was asked or not, so point to the link if its duplicate. I will delete this message

, , .

.

+4
2

- / , ID colClasses, , read.csv data.frame ÌD :

mydata<-read.csv("file.csv",colClasses=c("character","numeric"),...)
+1

R , 2147483647L.

L ( R a integer), :

x <- 12345678912345678912L
#Warning message:
#non-integer value 12345678912345678912L qualified with L; using numeric value 

, R double.

, gmp - . , , gmp.

+3

All Articles