Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- heads
- row1
- row2
- row3
- row4
- row5
- heads
- row3
- row5
- heads
- row1
- row2
- row4
- library(dplyr)
- anti_join(df, df1, by='heads')
- library(data.table)
- setkey(setDT(df), heads)[!df1]
- # heads
- # 1: row1
- # 2: row2
- # 3: row4
- setDT(df)[!df1, on = "heads"]
- fsetdiff(df, df1, all = TRUE)
- df[!df$heads %in% df1$heads,]
- df2 <- data.frame(heads = setdiff(df$heads, df1$heads))
- library(plyr)
- negate_match_df <- function (x, y, on = NULL)
- {
- if (is.null(on)) {
- on <- intersect(names(x), names(y))
- message("Matching on: ", paste(on, collapse = ", "))
- }
- keys <- join.keys(x, y, on)
- x[!keys$x %in% keys$y, , drop = FALSE]
- }
- df <- read.table(text ="heads
- row1
- row2
- row3
- row4
- row5",header=TRUE)
- df1 <- read.table(text ="heads
- row3
- row5",header=TRUE)
- negate_match_df(df,df1)
- library(sqldf)
- sql <- "SELECT t1.heads
- FROM df t1 LEFT JOIN df1 t2
- ON t1.heads = t2.heads
- WHERE t2.heads IS NULL"
- df2 <- sqldf(sql)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement