Check if data.table query returns empty result set
<p>I was wondering if there's a dedicated function to check if the result set returned by a data.table query is empty, i.e. zero rows. 
I tried to check which of the available ways is faster and surprisingly the usage of the stock function <code>nrow()</code> seems to be faster than using <code>.N</code> in data.table. Is this due to the size of the data.table I used in the example or a true in general?</p>

<pre><code>dt &lt;- structure(list(Abandon.Period = c(8135L, 1961L, 18307L, 4353L, 2270L, 7905L, 2600L, 2406L, 2286L, 2464L)
                 , Activity.Flag = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L))
                 , .Names = c("Random.Number", "Random.Integer")
                 , row.names = c(NA, -10L), class = c("data.table", "data.frame"))
microbenchmark(
    a = nrow(dt[Random.Number &lt; 1 ,]) == 0
    ,
    b = dt[Random.Number &lt; 1 ,.N] == 0
    , times = 1000
    )
Unit: microseconds
 expr     min       lq     mean   median      uq      max neval
    a 253.261 281.4845 306.5689 292.8045 309.407 3569.189  1000
    b 311.520 334.7630 354.3346 346.8375 361.931 3342.492  1000
</code></pre>

<p>Edit: </p>

<pre><code>dt &lt;- data.table(Random.Number = rnorm(100000))

microbenchmark(
        a = nrow(dt[Random.Number &lt; 1 ,]) == 0
        ,
        b = dt[Random.Number &lt; 1 ,.N] == 0
        , times = 1000
)
Unit: milliseconds
 expr      min       lq     mean   median       uq      max neval
    a 1.203515 1.287130 1.795557 1.331504 1.438513 85.51352  1000
    b 1.021796 1.093638 1.607488 1.128352 1.191289 90.10088  1000
</code></pre>