[datatable-help] [J(channel) , ] [J(chan) , ] give different results when chan=channel

Dieter Menne dieter.menne at menne-biomed.de
Thu Nov 8 17:45:28 CET 2012


I just got bitten by a nasty bug in my code:


library(data.table)
eso = data.table(pH=rnorm(10),channel=1:2,key="channel")
chan = 1
channel = chan

eso[J(chan)]    # not a column name, returns what I want
eso[J(channel)] # channel is a column and key, returns all

>From a standpoint of evaluation, it is clear to me what happens, but I find
this behavior highly confusing. I would wish if the latter could optionally
be flagged with a warning, in case this is not "by design".

Dieter





--
View this message in context: http://r.789695.n4.nabble.com/J-channel-J-chan-give-different-results-when-chan-channel-tp4648911.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list