Skip to content

accessing rows via a factor column throws error #1361

Closed

Description

@mplatzer

this used to work in data.table v1.9.4 but now throws an error in v1.9.6:

dt <- data.table(i=1:10, f=as.factor(1:10))
dt[f==3]

the thrown error is: Error in bmerge(i, x, leftcols, rightcols, io <- FALSE, xo, roll = 0, : x.'f' is a factor column being joined to i.'V1' which is type 'double'. Factor columns must join to factor or character columns.

the error can be avoided by adding additional conditions, e.g. dt[f==3 & TRUE] or by comparing to characters (as indicated by the error itself): dt[f=="3"]. not sure, whether this is a bug or a feature, but I though it's worthwhile reporting.

Activity

  1. caneff commented on Sep 28, 2015

    @caneff

    Running into this too. This seems to be very similar to isssue #957 but with factors instead of characters.

  2. caneff commented on Sep 28, 2015

    @caneff

    The problem seems to be that on line 471 of data.table.R, you check

    mode(x[[isub2]]) != mode(RHS)

    However, both factors and integers have mode "numeric", so it skips this part and moves on to the standard auto-indexing, where bmerge chokes. I'm not sure what the right substitution is for line 471 but that is where the fix should go.

  3. caneff commented on Oct 1, 2015

    @caneff

    Ping? This is breaking our existing code so we are stuck with 1.9.4 until this gets fixed.

  4. added this to the v1.9.8 milestone on Oct 6, 2015
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