filter_joins: Filtering joins filter rows from 'x' based on the presence or...

Description Usage Arguments Examples

Description

Usage

1
2
3
anti_join(x, y, by = NULL)

semi_join(x, y, by = NULL)

Arguments

x, y

The data.frames to join.

by

A character vector of variables to join by. If NULL, the default, *_join() will do a natural join, using all variables with common names across the two tables. A message lists the variables so that you can check they're right (to suppress the message, simply explicitly list the variables that you want to join).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
table1 <- data.frame(
  pupil = rep(1:3, each = 2),
  test = rep(c("A", "B"), 3),
  score = c(60, 70, 65, 80, 85, 70),
  stringsAsFactors = FALSE
)
table2 <- table1[c(1, 3, 4), ]

table1 %>% anti_join(table2, by = c("pupil", "test"))
table1 %>% semi_join(table2, by = c("pupil", "test"))

poorman documentation built on March 28, 2021, 5:05 p.m.