I would expect cbind(data.table(), dt[0]) to equal dt[0], but the operation seems to give a broken result with an added column V1 and shifted column types. Note how Species becomes NULL and Petal.Width ends up being a "Factor w/ 3 levels".
> dt <- as.data.table(iris)
> str(cbind(data.table(), dt[0]))
Classes ‘data.table’ and 'data.frame': 0 obs. of 6 variables:
$ V1 : num
$ Sepal.Length: num
$ Sepal.Width : num
$ Petal.Length: num
$ Petal.Width : Factor w/ 3 levels "setosa","versicolor",..:
$ Species : NULL
- attr(*, ".internal.selfref")=<externalptr>
I would expect
cbind(data.table(), dt[0])to equaldt[0], but the operation seems to give a broken result with an added columnV1and shifted column types. Note howSpeciesbecomesNULLandPetal.Widthends up being a "Factor w/ 3 levels".