View source: R/fjoin_functions.R
| fjoin_right_anti | R Documentation |
The anti-join of y in a join of x and y, i.e. the rows
of y that do not join.
fjoin_right_anti(
x = NULL,
y = NULL,
on,
match.na = FALSE,
mult.x = "all",
mult.y = "all",
select = NULL,
do = !(is.null(x) && is.null(y)),
show = !do
)
x, y |
|
on |
A character vector of join predicates, e.g. |
match.na |
Whether to allow equality matches between |
mult.x, mult.y |
When a row of |
select |
Character vector of columns to be selected from |
do |
Whether to execute the join. If |
show |
Whether to print the data.table code for the join to the
console. Default is the opposite of |
Details are as for e.g. fjoin_inner except for arguments
controlling the order and prefixing of output columns, which do not apply.
Output class is determined by y.
A data.frame, data.table, (grouped) tibble, sf,
or sf-tibble, or else NULL if do is FALSE. See
Details.
See the package-level documentation fjoin for related
functions.
# ---------------------------------------------------------------------------
# Semi- and anti-joins: basic usage
# ---------------------------------------------------------------------------
# data frames
x <- data.table::fread(data.table = FALSE, input = "
country pop_m
Australia 27.2
Brazil 212.0
Chad 3.0
")
y <- data.table::fread(data.table = FALSE, input = "
country forest_pc
Brazil 59.1
Chad 3.2
Denmark 15.8
")
# full join with `indicate = TRUE` for comparison
fjoin_full(x, y, on = "country", indicate = TRUE)
fjoin_semi(x, y, on = "country")
fjoin_anti(x, y, on = "country")
fjoin_right_semi(x, y, on = "country")
fjoin_right_anti(x, y, on = "country")
# ---------------------------------------------------------------------------
# `mult.x` and `mult.y` support
# ---------------------------------------------------------------------------
# data frames
events <- data.table::fread(data.table = FALSE, input = "
event_id event_ts
1 10
2 20
3 40
")
reactions <- data.table::fread(data.table = FALSE, input = "
reaction_id reaction_ts
1 30
2 50
3 60
")
# ---------------------------------------------------------------------------
# for each event, the next reaction, provided there was no intervening event (1:1)
fjoin_full(
events,
reactions,
on = c("event_ts < reaction_ts"),
mult.x = "first",
mult.y = "last",
indicate = TRUE
)
fjoin_semi(
events,
reactions,
on = c("event_ts < reaction_ts"),
mult.x = "first",
mult.y = "last"
)
fjoin_anti(
events,
reactions,
on = c("event_ts < reaction_ts"),
mult.x = "first",
mult.y = "last"
)
# ---------------------------------------------------------------------------
# Natural join
# ---------------------------------------------------------------------------
fjoin_semi(x, y, on = NA)
fjoin_anti(x, y, on = NA)
# ---------------------------------------------------------------------------
# Mock join
# ---------------------------------------------------------------------------
fjoin_semi(on="id")
fjoin_semi(on=c("id", "date"))
fjoin_semi(on=c("id"), mult.y = "last")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.