I would like to disable scientific notation when writing numbers to csv files in data.table. I can do that with write.csv
using options(scipen = 999)
but not with fwrite
.
Example:
require(data.table)
dt <- data.table("ID" = c("A", "B", "C", "D"), VALUE = c(0.0000001, 0.1234567, 1000000, 1234567))
options(scipen = 999)
write.csv(dt, row.names = FALSE)
# "ID","VALUE"
# "A",0.0000001
# "B",0.1234567
# "C",1000000
# "D",1234567
fwrite(dt, row.names = FALSE)
# ID,VALUE
# A,1e-07
# B,0.1234567
# C,1e+06
# D,1234567
I would like line A and C in fwrite to be written as in write.csv. I am using data.table version 1.10.0. Do you know how to do that?
format
i.e.dt <- dt[, lapply(.SD, format, scientific = FALSE)]
– akrun Apr 5 '17 at 9:40bit64::as.integer64
was an acceptable workaround for my use case. That won't help you with decimal places though. – C8H10N4O2 Nov 17 '17 at 22:23