Skip to content

Default colorder with setcolorder based off keys and indices #2895

@jsams

Description

@jsams

I'm proposing to have setcolorder(x) set the columns in the order specified by the keys, then remaining index columns, then the rest of the columns. I have a fork with the change already. Not sure if it would be welcome though. It makes for a nice mindless but sensible ordering to the data.

DT = data.table(a = 1:3, b = 2:4, c = 3:5)
setkey(DT, c)
setindex(DT, b)
all.equal(names(setcolorder(DT)),  c("c", "b", "a"))

Forked branch available here master...jsams:colorder_keys

Happy to make a PR if this is something that would be welcome (and sorry for the tracker spam the past few hours). Tried setting up the tests and such, but really, I have no idea what's going on with the testing framework here to be honest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions