join.tbl_df

0th

Percentile

Join data frame tbls.

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

Usage
# S3 method for tbl_df
inner_join(x, y, by = NULL, copy = FALSE,
  suffix = c(".x", ".y"), ...)

# S3 method for tbl_df left_join(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)

# S3 method for tbl_df right_join(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)

# S3 method for tbl_df full_join(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)

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

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

Arguments
x

tbls to join

y

tbls 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).

To join by different variables on x and y use a named vector. For example, by = c("a" = "b") will match x.a to y.b.

copy

If x and y are not from the same data source, and copy is TRUE, then y will be copied into the same src as x. This allows you to join tables across srcs, but it is a potentially expensive operation so you must opt into it.

suffix

If there are non-joined duplicate variables in x and y, these suffixes will be added to the output to diambiguate them.

...

included for compatibility with the generic; otherwise ignored.

Aliases
  • anti_join.tbl_df
  • full_join.tbl_df
  • inner_join.tbl_df
  • join.tbl_df
  • left_join.tbl_df
  • right_join.tbl_df
  • semi_join.tbl_df
Examples
library(dplyr) if (require("Lahman")) { batting_df <- tbl_df(Batting) person_df <- tbl_df(Master) uperson_df <- tbl_df(Master[!duplicated(Master$playerID), ]) # Inner join: match batting and person data inner_join(batting_df, person_df) inner_join(batting_df, uperson_df) # Left join: match, but preserve batting data left_join(batting_df, uperson_df) # Anti join: find batters without person data anti_join(batting_df, person_df) # or people who didn't bat anti_join(person_df, batting_df) }
Documentation reproduced from package dplyr, version 0.5.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.