Learn R Programming

ffbase2 (version 0.2)

join.tbl_ffdf: Join ffdf tbls.

Description

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

Usage

"inner_join"(x, y, by = NULL, copy = FALSE, ...)
"left_join"(x, y, by = NULL, copy = FALSE, ...)
"semi_join"(x, y, by = NULL, ...)
"anti_join"(x, y, by = NULL, ...)

Arguments

x,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 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.
...
Included for compatibility with generic; otherwise ignored.

Examples

Run this code
if (require(Lahman)){
data("Batting", package = "Lahman")
data("Master", package = "Lahman")

batting_ffdf <- tbl_ffdf(Batting)
person_ffdf <- tbl_ffdf(Master)

# Inner join: match batting and person data
inner_join(batting_ffdf, person_ffdf)

# Left join: keep batting data even if person missing
left_join(batting_ffdf, person_ffdf)

# 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_ffdf, grid, copy = TRUE)

# Anti-join: find batting data with out player data
anti_join(batting_ffdf, person_ffdf)
}

Run the code above in your browser using DataLab