<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I have come across some behavior in rbindlist that look unexpected to me:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><div id="bloop_customfont" style="margin: 0px;">> rbindlist(list(data.table(a=1, b=2), data.table(b=4, a=3)))</div><div id="bloop_customfont" style="margin: 0px;">   a b</div><div id="bloop_customfont" style="margin: 0px;">1: 1 2</div><div id="bloop_customfont" style="margin: 0px;">2: 4 3</div></div><div><br></div><div>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).</div><div><br></div><div>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. </div><div><br></div><div>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 behavior to avoid breaking backwards compatibility. </div><div><br></div><div>Or, at the very least, I suggest the documentation of bindlist 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.</div><br><div id="bloop_sign_1386080191204390912"><span style="font-family:helvetica,arial;font-size:13px"></span><div style="font-family: Helvetica; line-height: normal; ">-- </div><div style="font-family: Helvetica; line-height: normal; "><span style="font-family: arial; font-size: small; ">Alexandre Sieira</span><br style="font-family: arial; font-size: small; "><span style="font-family: arial; font-size: small; ">CISA, CISSP, ISO 27001 Lead Auditor</span><br style="font-family: arial; font-size: small; "><br style="font-family: arial; font-size: small; "><span style="font-family: arial; font-size: small; ">"The truth is rarely pure and never simple."</span><br style="font-family: arial; font-size: small; "><span style="font-family: arial; font-size: small; ">Oscar Wilde, The Importance of Being Earnest, 1895, Act I</span></div></div></body></html>