# Create a join block
new_join_block(type = "left_join")
if (interactive()) {
library(blockr.core)
library(blockr.dplyr)
# Basic left join - automatically detects common columns
serve(
new_board(
blocks = list(
data1 = new_dataset_block(dataset = "band_members"),
data2 = new_dataset_block(dataset = "band_instruments"),
joined = new_join_block(type = "left_join")
),
links = links(
from = c("data1", "data2"),
to = c("joined", "joined"),
input = c("x", "y")
)
)
)
# Inner join with explicit join column
serve(
new_board(
blocks = list(
data1 = new_dataset_block(dataset = "band_members"),
data2 = new_dataset_block(dataset = "band_instruments"),
joined = new_join_block(type = "inner_join", by = "name")
),
links = links(
from = c("data1", "data2"),
to = c("joined", "joined"),
input = c("x", "y")
)
)
)
# Right join - keep all rows from right dataset
serve(
new_board(
blocks = list(
data1 = new_dataset_block(dataset = "band_members"),
data2 = new_dataset_block(dataset = "band_instruments"),
joined = new_join_block(type = "right_join")
),
links = links(
from = c("data1", "data2"),
to = c("joined", "joined"),
input = c("x", "y")
)
)
)
# Anti join - find rows in left without matches in right
serve(
new_board(
blocks = list(
data1 = new_dataset_block(dataset = "band_members"),
data2 = new_dataset_block(dataset = "band_instruments"),
joined = new_join_block(type = "anti_join")
),
links = links(
from = c("data1", "data2"),
to = c("joined", "joined"),
input = c("x", "y")
)
)
)
}
Run the code above in your browser using DataLab