[datatable-help] Why does cbind drop key?
Matthew Dowle
mdowle at mdowle.plus.com
Tue Nov 15 19:39:20 CET 2011
On Tue, 2011-11-15 at 13:58 +0000, Matthew Dowle wrote:
> Just noticed you said cbind(DT,DF). That has been a saga, see FAQ 2.23,
> but it's ok for now.
>
> Ok, so we could easily change cbind.data.frame from
>
> > cbind.data.frame
> function (..., deparse.level = 1)
> {
> if (inherits(..1, "data.table"))
> return(data.table(...))
> data.frame(..., check.names = FALSE)
> }
>
> to
>
> > cbind.data.frame
> function (..., deparse.level = 1)
> {
> if (inherits(..1, "data.table"))
> return(data.table(...,key=key(..1)))
> data.frame(..., check.names = FALSE)
> }
Done.
> >> 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
> >>
> >
> >
> > _______________________________________________
> > 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
> >
>
>
> _______________________________________________
> 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