Skip to content
Justice Tech School

Merging Tables

merge joins two data frames on a shared column like a SQL join.

Example
a <- data.frame(id = 1:3, name = c("Ada", "Kofi", "Amina"))
b <- data.frame(id = c(1, 2, 4), score = c(90, 70, 60))
print(merge(a, b, by = "id"))
print(merge(a, b, by = "id", all.x = TRUE))

Exercise

Join key.

merge(a, b,  = "id")

Quiz Test

What does all.x = TRUE do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.