I stumbled into a strange behavior in R, where double values are not saved to a CSV as the original value.
Reproducible example:
set.seed(1)
df <- data.frame(ID = 1:10, X = rnorm(10))
write.csv(df, "test.csv", row.names = F)
read.csv("test.csv") == df
        ID     X
 [1,] TRUE FALSE
 [2,] TRUE FALSE
 [3,] TRUE FALSE
 [4,] TRUE FALSE
 [5,] TRUE FALSE
 [6,] TRUE FALSE
 [7,] TRUE FALSE
 [8,] TRUE FALSE
 [9,] TRUE FALSE
[10,] TRUE  TRUE
Granted, the difference appears to occur only at or after the 15th decimal digit, but it makes me uneasy to trust the CSV file.
options(digits = 20)
df[1,]
  ID                    X
1  1 -0.62645381074233242
read.csv("test.csv")[1,]
  ID                    X
1  1 -0.62645381074233197
Is there any way to circumvent this issue? Is it a known bug?
 
    