Skip to content

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

Closed

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).

Activity

  1. changed the title [-]Bug in R 3.1.1 incorrect string grouping behavior [/-] [+]Bug: With R 3.1.1 incorrect string grouping behavior in data.table[/+] on Jul 11, 2014
  2. arunsrinivasan commented on Jul 17, 2014

    @arunsrinivasan
    Member

    Fix for this bug (which is a duplicate of #481) was done in commit 86276f4. And DT[, col := list(list(.)), by=.] case was recently fixed in 5e2ced0.

    Should be all good now. Closing. Thanks @KrishnaPG for reporting!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions