Hi.
First I have to say that I basically love data.table :-)
However, recently I came across the following situation: I had a global variable AMOUNT_BAGS and I wanted to filter a certain data.table for ORDERED_NUMBER <= AMOUNT_BAGS. Unfortunately the table had a column named exactly like this: AMOUNT_BAGS (which contained nonsense numbers completely unrelated to what I was doing at this later point in time). I forgot about this column and the table was quite large in terms of columns (i.e. ~50 cols... not really 'large', I know, but large enougth so that one single column named AMOUNT_BAGS was not drawing attention). So data.table should have been confused because it should have been uncertain: "Does the user mean that I should compare the value in ORDERED_NUMBER to the respective value in the column AMOUNT_BAGS or should I compare the value in the column ORDERED_NUMBER against the global variable AMOUNT_BAGS?". However, it was not and it simply chose to compare the value in ORDERED_NUMBER against tha value in the respective value in the column AMOUNT_BAGS. This leads to the following awkward situation:
AMOUNT_BAGS = 10
x = data.table(ITEM = c("apple", "banana"), ORDERED_NUMBER = c(5,6), AMOUNT_BAGS = c(0, 0))
x = data.table(ITEM = c("apple", "banana"), ORDERED_NUMBER = c(5,6), AMOUNT_BAGS = c(0, 0))
all(x$ORDERED_NUMBER <= AMOUNT_BAGS)
x[ORDERED_NUMBER <= AMOUNT_BAGS]
# x is the empty table!
i.e. I check that all values in ORDERED_NUMBER are smaller than 10 but still they get filtered out!
Wouldn't it be nice to warn the user about this situation?
Regards,
Fabian Werner
_______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
