Two more things:
- I get an error when trying to write outside current wd; modifying slightly the example in
?fwrite:
fwrite(data.table(first=c(1,2), second=c(NA, 'foo"bar')), "~/Desktop/table.csv")
Error in
fwrite(data.table(first = c(1, 2), second = c(NA, "foo\"bar")),:
No such file or directory
- Handling for
listcolumns is probably incorrect. Not sure whether we should support... seems like it will be a good counterpart tosep2infread. As of now:
DT <- data.table(a = 1:3, l = list(list(1:6), list(3:5), list("a","b")))
fwrite(DT, "test.csv")
Produces:
"a","l"
1,list(1:6)
2,list(3:5)
3,list("a", "b")
I don't know the proper way to handle this, perhaps surround a list in angle brackets and comma-separate the elements?
"a","l"
1,<<1,2,3,4,5,6>>
2,<<3,4,5>>
3,<<"a">,<"b">>
?
Or perhaps take the cue from format.data.table:
format.item <- function(x) {
if (is.atomic(x) || is.formula(x))
paste(c(format(head(x, 6), justify = justify, ...),
if (length(x) > 6) ""), collapse = ",")
else paste("<", class(x)[1L], ">", sep = "")
}
if (is.list(col))
col = sapply(col, format.item)
else col = format(char.trunc(col), justify = justify, ...)
Otherwise just error on list columns