Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upConsistency in 'i' for integer and logical types #697
Comments
|
FR #633 title says "and maybe . and .. prefixes to symbols". There I was thinking . and .. on the symbols themselves. We do that anyway ourselves (manually) right? So it's really just building it in. ids = c("id1","id2")
DT[ids] # uses ids in calling scope because i is a single variable name
# on its own (rule in ?data.table). Common usage now.
DT[ logicalCol == TRUE ] # pretty clear, but possible mistakes if logicalCol
# isn't actually a column but is in calling scope
DT[ logicalCol ] # 'not found' currently but better error could suggest :
DT[ (logicalCol) ] # currently what I do to make it not a single name
DT[ .logicalCol ] # same, but error if no column is called "logicalCol"
# even if it does exist in calling scope (more robust)
DT[ colA > ..value ] # use 'value' in calling scope even if there's a column
# called "value". We do this manually currently by
# defining ..value in calling scope.
DT[ .colA > .colB ] # be explicit that colA and colB must be in DT
# otherwise error
DT[ colA > colB, strict.scope=TRUE] # same, without needing . prefixes
. and .. are really just an extension of the |
|
Okay, sounds good. |
|
On current master, this is the error:
For
So, it seems we could at least make the error message a bit more consistent:
|
Currently, there is one small inconsistency in row-subset using integer and logical types:
ias integer:The same happens for
logicaltype as well.The question is, can we get this indexing to work without the need for
(for cases whereiis a column inDTinstead of throwing the error?Edit: Cleaned up noise and retained just the resolution.