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

add function cbindlist #2576

Open
MichaelChirico opened this issue Jan 19, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@MichaelChirico
Copy link
Member

commented Jan 19, 2018

Inspired by this SO Q&A:

https://stackoverflow.com/q/48333523/3576984

dplyr::bind_cols syntax is appealingly clean.

cbindlist(X) would feel more data.table and provide the same functionality; even as a simple wrapper to setDT(unlist(X, recursive = FALSE)) this could be a nice convenience tool.

Not sure if there's any scope for further speedup under the hood as well.

@arunsrinivasan

This comment has been minimized.

Copy link
Member

commented Jan 20, 2018

Pretty neat! I don't think there's any concern for speed here.. But if one were to do cbindlist(X)[, col := new_val], then col from X would be updated as well. Probably documenting it would be sufficient..

@MichaelChirico

This comment has been minimized.

Copy link
Member Author

commented Jan 20, 2018

Duly noted, always good to remind side effects of mutability.

Would it be possible for setDT to do this internally, i.e. for setDT(X) to work (and be equally by-reference as setDT(unlist(X, recursive = FALSE))? Does it make sense for setDT to become that flexible, if so?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.