-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Here's the motivating example which had me mightily confused at first:
l = list(x=1,y=2)
data.frame(l)
# x y
#1 1 2
as.data.table(l)
# x y
#1: 1 2
data.table(l)
# l
#1: 1
#2: 2Now that I've explored this issue, I understand what's going on. But at the very least, there should be an entry in the faq about this.
The issue is that you might say data.table(listOne,listTwo) (or indeed, data.table(vectorOne,vectorTwo)) to create a two-column table, while as.data.table should only take one argument. Personally, I think the default here is wrong; it would make more sense, and be easier to troubleshoot bugs, if data.table(listOne) was the same as as.data.table(listOne), rather than being similar to data.table(listOne, listTwo).
This is touched on in the FAQ when it says "data.frame(list(1:2,"k",1:4)) creates 3 columns, data.table creates one list column." Still, I think that ideally the default should change: data.table with one argument should be the same as as.data.table. If not, this behavior should at least be better-documented.