Skip to content

dcast.data.table( drop = FALSE) does not fill missing factors #893

@matthieugomez

Description

@matthieugomez

dcast.data.table( drop = FALSE) does not add columns for missing levels in a factor variable

library(data.table)
library(reshape2)
df <- data.table(
    x = factor("a", levels = c("a", "b")),
    y = factor("b", levels = c("a", "b")),
    z = 1
  )
dcast(df, y~x, drop = FALSE)
dcast.data.table(df, y~x, drop = FALSE)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions