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 · May be fixed by #4370
Open

add function cbindlist #2576

MichaelChirico opened this issue Jan 19, 2018 · 2 comments · May be fixed by #4370
Assignees

Comments

@MichaelChirico
Copy link
Member

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
Copy link
Member

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
Copy link
Member Author

MichaelChirico 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants