Skip to content

rbindlist use.names = FALSE AND fill = TRUE #5037

Description

@SamuelAllain

Hello,

Rbindlist doesn't accept both use.names = FALSE and fill = TRUE, it automatically changes use.names = TRUE, which is not my desired behaviour. I would like

x y
1 A

bound with

z
4

to give

x y
1 A
4 NA
library(data.table)
l1 <- list(data.table(x = 1, y = "A"), data.table(z = 4))
l1

# what I want
data.table(x = c(1,4), y = c("A", NA)) 

rbindlist(l1, fill = T) # works but 3 columns

rbindlist(l1, use.names = FALSE) # doesn't work :
# Item 2 has 1 columns,
# inconsistent with item 1 which has 2 columns.
# To fill missing columns use fill=TRUE

rbindlist(l1, use.names = FALSE, fill = TRUE) # back to case 1
# use.names= cannot be FALSE when fill is TRUE. Setting use.names=TRUE.

The warning after rbindlist(l1, use.names = FALSE) recommending to add fill = TRUE is misleading because then it won't work.

Activity

  1. ben-schwen commented on Dec 7, 2021

    @ben-schwen
    Member

    Closed by #5263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions