[datatable-help] Selecting rows that don't match

Ben Goldstein ben.goldstein at gmail.com
Sat Aug 20 01:57:11 CEST 2011


Hello All,

I just started using data.table and like some of the features. I apologize
if this is a basic question, but I can't find it posted on the list. I want
to select the rows that don't match a key.

For example, in data.frame i'd do:

DF = data.frame(x=1:3,y=4:6,z=7:9)
ds <- c(1,2)
new.DF <- DF[which(! DF$x %in% ds),]

where, ds is a vector of values that I don't want matched. So, new.DF would
just consist of the third row.

How do I do something comparable with data.table?

I have:
DT = data.table(DF)
setkey(DT,x)
and then I know I can select ds, by:
DT[ds]
but something like:
DT[!ds] obviously doesn't work...

Thanks,

Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20110819/dd2a654c/attachment.htm>


More information about the datatable-help mailing list