Skip to content

add function cbindlist #2576

Closed
Closed

Description

@MichaelChirico

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.

Activity

  1. arunsrinivasan commented on Jan 20, 2018

    @arunsrinivasan
    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..

  2. MichaelChirico commented on Jan 20, 2018

    @MichaelChirico
    MemberAuthor

    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?

  3. linked a pull request that will close this issuecbindlist, mergelist #4370on Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions