Reported from this SO question:
I've stumbled upon weird data table i behavior that returns a row with NAs where I would expect an empty data table. See:
a = data.table(a = 1, d = NA)
a[!is.na(a) & d == "3"]
# a d
#1: NA NA
I would expect an empty data table as a result here.
Compare to:
a = data.table(a = c(1,2), d = c(NA,3))
a[!is.na(a) & d == "3"]
# a d
#1: 2 3
This one does not produce an extra row with NA values, though.
> sessionInfo()
# R version 2.15.2 (2012-10-26)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
#
# locale:
# [1] LC_COLLATE=English_United Kingdom.1252
# [2] LC_CTYPE=English_United Kingdom.1252
#
# [3] LC_MONETARY=English_United Kingdom.1252
# [4] LC_NUMERIC=C
#
# [5] LC_TIME=English_United Kingdom.1252
#
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
Reported from this SO question:
I've stumbled upon weird data table
ibehavior that returns a row withNAs where I would expect an empty data table. See:I would expect an empty data table as a result here.
Compare to:
This one does not produce an extra row with
NAvalues, though.