Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:40:27+00:00 2026-06-11T00:40:27+00:00

What happens if I want to select all the rows in a data.table that

  • 0

What happens if I want to select all the rows in a data.table that do not contain a particular value in the key variable using binary search? By the way, what is the correct jargon for what I want to do? Is it “nojoin”? Is it “negative selection”?

DT = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)
setkey(DT,x)

Lets do a positive selection for all rows where x==”a” but using binary search

DT["a"]

That’s beautiful but I want the opposite of that. I want all the rows that are not “a” in other words where x!=”a”

DT[x!="a"]

That is a vector scanning. The above line works but is uses vector scanning. I want to use binary. I was expecting the following to work, but alas…

DT[!"a"]
DT[-"a"]

The above two do not work and trying to play with nomatch got me nowhere.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:40:28+00:00Added an answer on June 11, 2026 at 12:40 am

    The idiom is this:

    DT[-DT["a", which=TRUE]]
    
       x y v
    1: b 1 4
    2: b 3 5
    3: b 6 6
    4: c 1 7
    5: c 3 8
    6: c 6 9
    

    Inspiration from:

    • The mailing list posting Return Select/Join that does NOT match?
    • The previous question non-joins with data.tables
    • Matthew Dowle’s answer to Porting set operations from R’s data frames to data tables: How to identify duplicated rows?

    Update. New in v1.8.3 is not-join syntax. Farrel’s first expectation (! rather than -) has been implemented :

    DT[-DT["a",which=TRUE,nomatch=0],...]   # old idiom
    DT[!"a",...]                            # same result, now preferred.
    

    See the NEWS item for more detailed info and example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a data.table and I want to select all the rows
I'm using this code to try and select all of the text in the
Problem: When I use an auto-incrementing primary key in my database, this happens all
Is there a way to select every nth child that matches (or does not
I have many cursors that all return rows with the same fields: a numeric
Problem I want the capabilities of JXTable with the select all on edit behavior
I am writing a trigger to keep track of all the changes that happens
I have a table in the database that I'm retrieving using LINQ to SQL,
I want to know what actually happens when you annotate a method with @Transactional
I want to know what happens when I create an instance of a ServiceHost

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.