Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
SamuelAllain opened this issue Jun 4, 2021 · 1 comment · Fixed by #5263
Closed

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

SamuelAllain opened this issue Jun 4, 2021 · 1 comment · Fixed by #5263

Comments

@SamuelAllain
Copy link

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.

@ben-schwen
Copy link
Member

Closed by #5263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants