lhs <- data.table::data.table(x = rep(c("b", "a", "c"), each = 3),
y = c(1, 3, 6),
v = 1:9)
rhs <- data.table::data.table(x = c("c", "b"),
v = 8:7,
foo = c(4, 2))
rhs %>%
anti_join(lhs, x, v)
lhs %>%
inner_join(rhs, x)
# creates new data.table
lhs %>%
left_join(rhs, x)
# would modify lhs by reference
lhs %>%
start_expr %>%
mutate_join(rhs, x, .SDcols = c("foo", rhs.v = "v"))
# would modify rhs by reference, summarizing 'y' before adding it.
rhs %>%
start_expr %>%
mutate_join(lhs, x, .SDcols = .(y = mean(y)))
# creates new data.table
lhs %>%
right_join(rhs, x)
# keep only columns from lhs
lhs %>%
semi_join(rhs, x)
Run the code above in your browser using DataLab