DT in a DT[i]-style join of data frame-like
objectsWrite (and optionally run) data.table code to return the semi-join of
DT (the rows of DT that join with i) using a
generalisation of DT[i] syntax.
The functions fjoin_left_semi and fjoin_right_semi
provide a more conventional interface that is recommended over
dtjoin_semi for most users and cases.
dtjoin_semi(
.DT = NULL,
.i = NULL,
on,
match.na = FALSE,
mult = "all",
mult.DT = "all",
nomatch = NULL,
nomatch.DT = NULL,
select = NULL,
do = !(is.null(.DT) && is.null(.i)),
show = !do,
verbose = FALSE,
...
)A data.frame, data.table, (grouped) tibble, sf,
or sf-tibble, or else NULL if do is FALSE. See
Details.
data.frame-like objects (plain, data.table, tibble,
sf, list, etc.), or else both omitted for a mock join
statement with no data.
A character vector of join predicates, e.g. c("id", "col_DT
== col_i", "date < date", "cost <= budget"), or else NA for a
natural join (an equality join on all same-named columns).
If TRUE, allow equality matches between NAs or
NaNs. Default FALSE.
(as in [.data.table) When a row of .i has multiple
matching rows in .DT, which to accept. One of "all" (the
default), "first", or "last".
Permitted for consistency with dtjoin but
has no effect on the resulting semi-join.
Permitted for consistency with dtjoin but
have no effect on the resulting semi-join.
Character vector of columns of .DT to be selected.
NULL (the default) selects all columns. Join columns are always
selected.
Whether to execute the join. Default is TRUE unless
.DT and .i are both omitted/NULL, in which case a mock
join statement is produced.
Whether to print the code for the join to the console. Default is
the opposite of do. If .DT and .i are both
omitted/NULL, mock join code is displayed.
(passed to [.data.table) Whether data.table should
print information to the console during execution. Default FALSE.
Further arguments (for internal use).
Details are as for dtjoin except for arguments controlling
the order and prefixing of output columns, which do not apply.
See the package-level documentation fjoin for related
functions.
# Mock joins
dtjoin_semi(on = "id")
dtjoin_semi(on = c("id", "date <= date"))
dtjoin_semi(on = c("id", "date <= date"), mult = "last")
Run the code above in your browser using DataLab