<div dir="ltr">Indeed, it shows that k1 and k2 both have names of length 2, and both times the value of names is just the variable names.<div><br></div><div>Where the names are getting added is by apply.  What the issue with data.table is that it does not ignore names from short variables. I now have a small reproducible example I can share:</div>


<div><br></div><div>d <- data.frame(x=1:5)</div><div><br></div><div>f <- function(x) {data.table(x=x, y=1:10)}</div><div><br></div><div>l <- apply(d, 1, f)</div><div><br></div><div>lapply(l, function(x) lapply(x, names)) # All values of x have a name</div>


<div><br></div><div>a <- rbindlist(l) # a$x will segfault after this</div><div><br></div><div><br></div><div>The underlying issue is what data.table and data.frame do with rownames and recycling. Look at this simple case:</div>


<div><br></div><div>x <- 1:5</div><div>names(x) <- letters[1:5]</div><div><br></div><div>df <- data.frame(x=x, y=1:10) </div><div>#Warning message:</div><div>#  In data.frame(x = x, y = 1:10) :</div><div>#  row names were found from a short variable and have been discarded</div>


<div><br></div><div>lapply(df, names) # no names</div><div><br></div><div>dt <- data.table(x=x, y=1:1) # No warning</div><div><br></div><div>lapply(dt, names) # x has names, and they get recycled.</div><div><br></div>

<div>
<br></div><div>So data.table needs to follow data.frame logic for discarding row names when they would otherwise be recycled. </div><div><br></div><div><br></div><div>Bug submitted here: <a href="https://r-forge.r-project.org/tracker/index.php?func=detail&aid=4890&group_id=240&atid=975">https://r-forge.r-project.org/tracker/index.php?func=detail&aid=4890&group_id=240&atid=975<br>

</a></div><div>I'm surprised this has never arisen before, it seems like something that has been around forever.</div></div>