I use data.table quite a lot. It works well, but I find that it takes me a long time to translate my syntax so that it takes advantage of binary search.
In the following data table, how to 1 select all rows, including the CPT NA value, but exclude rows where the CPT value is 23456 or 10000.
cpt <- c(23456,23456,10000,44555,44555,NA) description <- c("tonsillectomy","tonsillectomy in >12 year old","brain transplant","castration","orchidectomy","miscellaneous procedure") cpt.desc <- data.table(cpt,description) setkey(cpt.desc,cpt)
The next line works, but I think it uses a vector check method instead of a binary search (or binary exception). Is there a way to discard strings by binary methods?
cpt.desc[!cpt %in% c(23456,10000),]
source share