Join data table tbls.

See join for a description of the general purpose of the functions.

# S3 method for tbl_dt
inner_join(x, y, by = NULL, copy = FALSE, ...)

# S3 method for tbl_dt left_join(x, y, by = NULL, copy = FALSE, ...)

# S3 method for tbl_dt semi_join(x, y, by = NULL, copy = FALSE, ...)

# S3 method for tbl_dt anti_join(x, y, by = NULL, copy = FALSE, ...)

tbls to join
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, supply a character vector.
If y is not a data table or tbl_dt and copy is TRUE, y will be converted into a data table.
Included for compatibility with generic; otherwise ignored.
  • anti_join.tbl_dt
  • inner_join.tbl_dt
  • join.tbl_dt
  • left_join.tbl_dt
  • semi_join.tbl_dt
if (require("RSQLite")) {
data("Batting", package = "Lahman")
data("Master", package = "Lahman")

batting_dt <- tbl_dt(Batting)
person_dt <- tbl_dt(Master)

# Inner join: match batting and person data
inner_join(batting_dt, person_dt)

# Left join: keep batting data even if person missing
left_join(batting_dt, person_dt)

# Semi-join: find batting data for top 4 teams, 2010:2012
grid <- expand.grid(
  teamID = c("WAS", "ATL", "PHI", "NYA"),
  yearID = 2010:2012)
top4 <- semi_join(batting_dt, grid, copy = TRUE)

# Anti-join: find batting data with out player data
anti_join(batting_dt, person_dt)
Documentation reproduced from package dplyr, version 0.1.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.