You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the meantime, a workaround here is to specify a different na character (the default is ""). Note that the readLines of foo.sdv shows two spaces between 1 and 3, so fwrite is working as intended, and thus the issue--if there is one--is with fread. It may or may not be reasonable to expect fread to parse those two spaces as separators with a missing value between them--someone who understands all the complexities of fread would need to weigh in.
foo<-data.frame(a=1, b=NA, c=3)
data.table::fwrite(foo, file='foo.sdv', sep='')
data.table::fread('foo.sdv')
#> Warning in data.table::fread("foo.sdv"): Detected 3 column names but the data#> has 2 columns. Filling rows automatically. Set fill=TRUE explicitly to avoid#> this warning.#> a b c#> 1: 1 3 NA
readLines("foo.sdv")
#> [1] "a b c" "1 3"data.table::fwrite(foo, file='foo2.sdv', sep='',na="NA")
readLines("foo2.sdv")
#> [1] "\"a\" \"b\" \"c\"" "1 NA 3"data.table::fread('foo2.sdv')
#> a b c#> 1: 1 NA 3
You do get a warning but you also get a silent kind of "column reordering." This could lead to tricky and insidious wrong results:
The text was updated successfully, but these errors were encountered: