Skip to content

bug? rbindlist idcol constructed incorrectly #1432

@franknarf1

Description

@franknarf1

Looking at this SO question

# http://stackoverflow.com/questions/33661645/r-number-of-non-na-records-by-column-grouped
list_1 <- list(a = c(44,47), dens = c(2331,1644))
list_2 <- list(a=66, dens= 1890)
list_3 <- list(a=c(44,46,48,50), dens=c(8000,1452,1596,7521)) 
mylist <- list(list_1, list_2, list_3)
names(mylist)<-c("ID_1","ID_2","ID_3")

I thought I could use rbindlist, but

rbindlist(mylist, id=TRUE)

    .id  a dens
1: ID_1 44 2331
2: ID_1 47 1644
3: ID_2 66 1890
4: ID_2 44 8000
5: ID_3 46 1452
6: ID_3 48 1596
7: ID_1 50 7521
Warning message:
In set(ans, j = idcol, value = rep.int(nm, len)) :
  Supplied 6 items to be assigned to 7 items of column '.id' (recycled leaving remainder of 1 items).

As suggested by the warning, the final .id is wrong. I see the same warning with various subsets of mylist.

By the way, the "How to file a bug report" link is still dead over here: https://github.com/Rdatatable/data.table/blob/master/Contributing.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions