Skip to content

setnames(x, new) fails if somehow anyNA(names(x)) #2475

@franknarf1

Description

@franknarf1

The data.table interface to names don't seem to support making one NA, but if it does happen, it cannot be fixed with setnames(x, new):

x = setNames(data.frame(a = 1, b = 2), c(NA, "b"))

library(data.table)
setDT(x)
setnames(x, c("a", "b"))
names(x)
# [1] NA  "b"

From user3496254 SO: https://stackoverflow.com/questions/47228836/r-data-table-bug-cannot-rename-column-names-which-are-na

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