Skip to content

Let setnames accept negative integers for the 'old' argument #1443

@richierocks

Description

@richierocks

If I want to change all the column names except the first, for example, currently I have to do something like

DT <- data.table(x = 1:3, y = 4:6, z = 7:9)
setnames(DT, seq_along(DT)[-1], c("m", "n"))

It would be convenient if I could pass negative integers to old, in order to write

setnames(DT, -1, c("m", "n"))

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions