The easy section demonstrates fundamental merging techniques using the merge()
function in R's data.table library.
-
Simple Merge (Default)
- Returns only rows with matching IDs in both tables
- Equivalent to an inner join
- Result includes only students B and C
-
Left Join (
all.x = TRUE
)- Keeps all rows from the left table (students)
- Missing values are filled with NA
- Result includes all students A, B, C, D
-
Right Join (
all.y = TRUE
)- Keeps all rows from the right table (scores)
- Missing values are filled with NA
- Result includes students B, C, and E
-
Full Outer Join (
all = TRUE
)- Keeps all rows from both tables
- Missing values are filled with NA
- Result includes students A, B, C, D, and E
The medium section introduces a more advanced merges()
function that provides flexible merging capabilities.
- Automatically detects common columns for merging
- Allows manual specification of merge columns
- Supports merging three tables in a single operation
- Auto-detect common columns
- Specify specific columns for merging
- Handle different column names between tables
- Merge multiple tables with various joining strategies
The DBmaps
package provides tools for exploring, mapping, and merging tables in relational databases. It simplifies the process of understanding database structures, identifying relationships between tables, and automating the merging of data from multiple tables.