Skip to content

Instantly share code, notes, and snippets.

@safferli
Created July 16, 2015 08:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save safferli/164f1ed49d32e1081459 to your computer and use it in GitHub Desktop.
remove all instances in first table that exist in second table
library(data.table)
library(dplyr)
a <- data.table(x = c("A", "B", "C", "D"),
y = c(1, 2, 3, 4),
z = c("good", "bad", "bad", "good")) %>%
setkey(x, y)
b <- data.table(x = c("B", "C"),
y = c(2, 3)) %>%
setkey(x, y)
c <- a[!b]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment