Joining Data with dplyr
Run the hidden code cell below to import the data used in this course.
1 hidden cell
Take Notes
Add notes about the concepts you've learned and code cells with code you want to keep.
Add your notes here
# Add your code snippets here#Parts
Rows: 17,501
Columns: 3
#parts_categories
Rows: 64
Columns: 2
Add the correct verb, table, and joining column
parts %>% inner_join(part_categories, by = c(part_cat_id = id)) Error: join columns must be character vectors.
Add the correct verb, table, and joining column
parts %>% inner_join(part_categories, by = c("part_cat_id" = "id"))
A tibble: 17,501 × 4
part_num name.x part_cat_id name.y
1 0901 Baseplate 16 x 30 with Set 080 Yellow … 1 Baseplates
2 0902 Baseplate 16 x 24 with Set 080 Small W… 1 Baseplates
3 0903 Baseplate 16 x 24 with Set 080 Red Hou… 1 Baseplates
4 0904 Baseplate 16 x 24 with Set 080 Large W… 1 Baseplates
5 1 Homemaker Bookcase 2 x 4 x 4 7 Containers
6 10016414 Sticker Sheet #1 for 41055-1 58 Stickers
7 10026stk01 Sticker for Set 10026 - (44942/4184185) 58 Stickers
8 10039 Pullback Motor 8 x 4 x 2/3 44 Mechanical
9 10048 Minifig Hair Tousled 65 Minifig Headw…
10 10049 Minifig Shield Broad with Spiked Botto… 27 Minifig Acces…
… with 17,491 more rows
Use the suffix argument to replace .x and .y suffixes
parts %>% inner_join(part_categories, by = c("part_cat_id" = "id"), suffix = c("_part","_category"))
A tibble: 17,501 × 4
part_num name_part part_cat_id name_category
1 0901 Baseplate 16 x 30 with Set 080 Yello… 1 Baseplates
2 0902 Baseplate 16 x 24 with Set 080 Small… 1 Baseplates
3 0903 Baseplate 16 x 24 with Set 080 Red H… 1 Baseplates
4 0904 Baseplate 16 x 24 with Set 080 Large… 1 Baseplates
5 1 Homemaker Bookcase 2 x 4 x 4 7 Containers
6 10016414 Sticker Sheet #1 for 41055-1 58 Stickers
7 10026stk01 Sticker for Set 10026 - (44942/41841… 58 Stickers
8 10039 Pullback Motor 8 x 4 x 2/3 44 Mechanical
9 10048 Minifig Hair Tousled 65 Minifig Headwear
10 10049 Minifig Shield Broad with Spiked Bot… 27 Minifig Accesso…