Skip to content

Number of rows and list columns with NULL #7637

@sluga

Description

@sluga

The following snippet produces what it should, i.e. a list column axis with NULL values.

library(data.table) # v1.18.0

dt1 <- data.table(var_name = c("foo", "bar"))
dt1[, axis := lapply(var_name, \(v) NULL)]

But if the table happens to contain a single row, it attempts to remove the column instead, i.e. it behaves like dt2[, axis := NULL] would.

dt2 <- data.table(var_name = c("foo"))
dt2[, axis := lapply(var_name, \(v) NULL)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions