Writing a csv with the write_csv() function from package readr seems to treat numbers differently depending on trailing zeros.
- 4001705344 is saved as is, but
- 4100738000 is saved as 4100738e3 in the csv.
This causes problems when I reopen the csv (e.g. in Excel).
For a reproducible example s.
library(readr)
x <- c(4100750938, 4104806156, 4001682199, 4100738000)
df <- data.frame(x)
write_csv(df, "df.csv")
The result is
x
4100750938
4104806156
4001682199
4100738e3
The expected result is
x
4100750938
4104806156
4001682199
4100738000
The only thing that helps is to save x as a character vector, which keeps the 000 intact and produces the expected output.
library(readr)
x <- c(4100750938, 4104806156, 4001682199, 4100738000)
x <- as.character(x)
df <- data.frame(x)
write_csv(df, "df.csv")
But is there another way? And is write_csv() behaving correctly here?
I use readr_1.1.1 on R version 3.3.3 (2017-03-06) Platform: x86_64-w64-mingw32/x64 (64-bit)
Browsing other Questions I found write_csv read_csv with scientific notation after 1000th row but that seems do be a different question to me.