Open
Description
Hi,
first thank you for this package. :)
I had a problem when saving and reading a csv with fread and fwrite
library(data.table)
dt <- data.table(a = c(NA_integer_, 1L, 2L), b = c("a", "b", NA_character_))
tmp <- tempfile()
fwrite(dt, tmp)
dt2 <- fread(tmp)
dt
# a b
#1: NA a
#2: 1 b
#3: 2 NA
dt2
# a b
#1: NA a
#2: 1 b
#3: 2
all.equal(dt,dt2)
#[1] "Column 'b': 'is.NA' value mismatch: 0 in current 1 in target"
So I realised fread and fwrite have different default for na(-strings), so I checked read.csv and write.csv and they use the same default option.
In the end it mixes empty strings with NA which is not an expected default behavior imho.
Shouldn't fwrite use the same default option as write.csv i.e. na = "NA" or NA? so that a call to fread after fwrite would recover the same object?
Cheers,
Benoit