Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R data.table i = MYVAR != %like% "something|somethingelse|somethingmore",

Tags:

r

data.table

I have a general form for a data.table query where I can subset my data to only look at values that match the %like% statement, it looks like

DT[Var %like% "x|y|z", .N,]

And for the general operators for excluding values

i = x != "somevalue",

How can I combine these to ignore values that sound %like% some value and only return a set that don't match these requests.

The context here is a large database of customer data and trying to remove unwanted data so this list is much smaller than the list I am interested in.

like image 493
digdeep Avatar asked Oct 23 '25 18:10

digdeep


1 Answers

I think you are looking for

DT[!(var %like% 'expr')]

Information on other logical operators can be found on the same help page; type ?`!` in the console to open it.

like image 97
Frank Avatar answered Oct 26 '25 06:10

Frank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!