Skip to content

rbindlist SET_STRING_ELT error when DT has ordered variables #899

Closed

Description

@ChristK

Please see following example:

    require(data.table)
    DT1 = data.table(A = factor(1:2), B = factor(6:10), C = 0)
    DT2 = data.table(D = ordered(1:5), A = factor(1:2), C = 0)
    DT3 = data.table(A = factor(1:2), C = 0)
    l = list(DT1, DT2, DT3)
    rbindlist(l, use.names = T, fill = T)

The above returns:

     #Error in rbindlist(l, use.names = T, fill = T) : 
     # attempt to set index 6/6 in SET_STRING_ELT

When colD in DT2 is a factor instead of ordered factor, rbindlist works as expected:

    DT2 = data.table(D = factor(1:5), A = factor(1:2), C = 0)
    l = list(DT1, DT2, DT3)
    rbindlist(l, use.names = T, fill = T)
     #  A  B C  D
     #1: 1  6 0 NA
     #2: 2  7 0 NA
     #3: 1  8 0 NA
     #4: 2  9 0 NA
     #5: 1 10 0 NA
     #6: 1 NA 0  1
     #7: 2 NA 0  2
     #8: 1 NA 0  3
     #9: 2 NA 0  4
    #10: 1 NA 0  5
    #11: 1 NA 0 NA
    #12: 2 NA 0 NA

Reproducible in R v3.1.1 x64, data.table v1.9.5, Windows 8.1 x64 and LinuxMint x64

Activity

  1. added this to the v1.9.6 milestone on Oct 19, 2014
  2. ChristK commented on Oct 19, 2014

    @ChristK
    Author

    Thank you for the super-fast fix

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions