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
Submitted by: Alexandre Sieira; Assigned to: Arun ; R-Forge link
I have come across some behaviour in rbindlist that look unexpected to me:
rbindlist(list(data.table(a=1, b=2), data.table(b=4, a=3)))
# a b
#1: 12
#2: 43
So it appears to assume (without checking) that all objects have not only the same column names but also the same column order. So a value assigned to column ‘a’ in the second object was used for column ‘b’ in the end result (and vice-versa).
I know the documentation says rbindlist uses the column types from the first entry of the list, but I didn’t see any mention to column order or names anywhere.
I suggest that column names are matched, even if they are not in the same order. Perhaps a use.names parameter could be used to ask for this behaviour to avoid breaking backwards compatibility.
Or, at the very least, I suggest the documentation of rbindlist be updated to explicitly mention that the columns will be considered by position only, and that callers need to ensure the column orders of all objects match exactly. And that a warning is issued by rbindlist when the column names don’t match.
The text was updated successfully, but these errors were encountered:
Submitted by: Alexandre Sieira; Assigned to: Arun ; R-Forge link
I have come across some behaviour in
rbindlist
that look unexpected to me:So it appears to assume (without checking) that all objects have not only the same column names but also the same column order. So a value assigned to column ‘a’ in the second object was used for column ‘b’ in the end result (and vice-versa).
I know the documentation says
rbindlist
uses the column types from the first entry of the list, but I didn’t see any mention to column order or names anywhere.I suggest that column names are matched, even if they are not in the same order. Perhaps a
use.names
parameter could be used to ask for this behaviour to avoid breaking backwards compatibility.Or, at the very least, I suggest the documentation of
rbindlist
be updated to explicitly mention that the columns will be considered by position only, and that callers need to ensure the column orders of all objects match exactly. And that a warning is issued byrbindlist
when the column names don’t match.The text was updated successfully, but these errors were encountered: