[datatable-help] Ordering of filter expressions

Johann Hibschman jhibschman at gmail.com
Mon Dec 15 15:26:21 CET 2014


I finally had time to put together a minimal example:

    > d <- data.table(a=1:2, b=1:2)
    > d[round(a) == a]
       a b
    1: 1 1
    2: 2 2
    > d[a == round(a)]
    Error in eval(expr, envir, enclos) : object 'a' not found

Is this a bug, or am I missing something about the scoping rules?

R 3.1.2, data.table 1.9.4, on Windows 7.

Thanks,
Johann

On Fri, Dec 12, 2014 at 10:18 AM, Johann Hibschman <jhibschman at gmail.com> wrote:
> I just ran into an issue where d[X==round(X)] gives different results
> from d[round(X) == X]. Why would that happen?
>
> Here's the exact example:
>
>> z.dev[YIELD == round(YIELD),]
> Error in eval(expr, envir, enclos) : object 'YIELD' not found
>> z.dev[round(YIELD) == YIELD,]
>    runId dealName     cusip scenarioId shockId pathOrder PRICE100
> YIELD MOD_DURN MOD_CONVEXITY DISC_MARGIN SPREAD_BP
> 1: 10556 HVML0501 41161PLE1        772       0         3  54.5094
> 6    4.739         0.431         400       418
> 2: 10556 HVML0501 41161PLE1        773       0         3  52.9452
> 6    4.706         0.427         400       424
>
> Thanks,
> Johann


More information about the datatable-help mailing list