Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cbind of zero-row data.table with empty data.table messes up columns #3445

Closed
mb706 opened this issue Mar 7, 2019 · 0 comments · Fixed by #3446
Closed

cbind of zero-row data.table with empty data.table messes up columns #3445

mb706 opened this issue Mar 7, 2019 · 0 comments · Fixed by #3446
Assignees
Milestone

Comments

@mb706
Copy link

@mb706 mb706 commented Mar 7, 2019

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]))
Classesdata.tableand '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> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants