Skip to content

Bug: With R 3.1.1 incorrect string grouping behavior in data.table #728

@KrishnaPG

Description

@KrishnaPG

Please check the below code output:

ids <- c(10, 10, 10, 11, 12, 12)
items <- c('soup', 'rice', 'lemon', 'chicken', 'lamb', 'noodles')

orders <- as.data.table(list(id=ids, item=items))
orders[,list(list(item)), by=id]

On R 3.1.1 it is producing the below (incorrect) output:

   id                 V1
1: 10 lamb,noodles,lemon
2: 11 lamb,noodles,lemon
3: 12 lamb,noodles,lemon    

where as it should be as below:

   id                 V1
1: 10 soup,rice,lemon
2: 11 chicken
3: 12 lamb,noodles

I remember this working correctly in earlier R versions, after upgrading to latest 3.1.1 started encountering this problem. (Or, if it is my mistake and I am doing something wrong, please correct me, Thanks).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions