Skip to content

single symbol in j behaves strangely #2983

Closed

Description

@franknarf1

I was trying to do a cross join on a couple small tables:

library(data.table)
# data.table 1.11.5 IN DEVELOPMENT built 2018-07-11 03:11:00 UTC; travis  Latest news: http://r-datatable.com
idDT  = data.table(id = 1:2)
varDT = data.table(v = letters[1:3], x = 4:6)

idDT[, varDT, by=id]
# Error in FUN(X[[i]], ...) : 
#   Invalid column: it has dimensions. Can't format it. If it's the result of data.table(table()), use as.data.table(table()) instead.

idDT[, (varDT), by=id]
# as expected

So it didn't recognize that varDT is a list of columns (which is what we typically want in j, from my understanding). If I use a list instead of a data.table...

>     L = as.list(varDT); idDT[, L, by=id]
   id     L
1:  1 a,b,c
2:  1 4,5,6
3:  2 a,b,c
4:  2 4,5,6

... something different but still weird/wrong happens. I thought maybe I needed to use the .. prefixes since I'm accessing an object one level up, but no dice there either:

>     L = as.list(varDT); idDT[, ..L, by=id]
Error in `[.data.table`(idDT, , ..L, by = id) : 
  Internal error:  DT[, ..var] should be dealt with by the branch above now.

I also tried options(datatable.WhenJisSymbolThenCallingScope=TRUE) from the FAQ but saw the same behavior.

If there's logic assuming that any bare symbol in j should be a single column, I guess it would make more sense to assume it's a list of columns (since that's what j should contain, at least when by= is present).

Activity

  1. MichaelChirico commented on Jul 22, 2018

    @MichaelChirico
    Member

    Related: #1090, #814, #1717, #2343

  2. added
    non-atomic column
    on Apr 5, 2020
  3. jangorecki commented on Apr 5, 2020

    @jangorecki
    Member

    AFAIK duplicate of #1473

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

    duplicatenon-atomic column

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions