Skip to content

setDF's rownames argument could be a column to be converted to row names #1719

@MichaelChirico

Description

@MichaelChirico

Say we had

DT <- data.table(a = c("a", "b", "c"), b = 1:3)

And we wanted

data.frame(b = 1:3, row.names = c("a", "b", "c"))

It seems we could do this all by reference via:

rn <- DT$a
DT[ , a := NULL]
setDF(DT, rownames = rn)

Seems natural to implement this via

setDF(DT, rownames = "a")

Or else add an argument:

setDF(DT, to.row.names = "a")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions