[datatable-help] Why does cbind drop key?

Matthew Dowle mdowle at mdowle.plus.com
Tue Nov 15 14:42:20 CET 2011


Good point. Could you add a comment to FR#295 and perhaps embelish the
title to include cbind please.

https://r-forge.r-project.org/tracker/index.php?func=detail&aid=295&group_id=240&atid=978

A reason for not setting the key attribute after cbind may have been speed
because attr<- takes a copy of the whole object (it triggers copy-on-write
when called within a function). At least, that's what I thought at the
time perhaps. We now have an internal function to set attributes by
reference, so it's pretty easy to do that now.

But, := is much much better if you can.


> When I do cbind(DT, DF), where DT has a key, the result loses the key.
>  cbind can't change ordering though, so why does that happen?  I can
> understand if you are trying to combine two keyed DT's that the result
> is ambiguous, but it isn't in this case.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>




More information about the datatable-help mailing list