7 Joins: Merging Data Sets with Keys

🕵 A Crime Has Been Committed! Can You Help Solve it?

A crime has taken place, and the detective needs your help! You’ve been given special access to the police database to crack the case. Let’s dive in and see if you can uncover the truth!

To help you navigate the data, here’s a database schema: a diagram that shows how the tables are connected. It’s like a map to guide you through the investigation:

👉 Tip: Click this link to open the schema in a new tab for easy reference as you work through the mystery.

2 New Functions to Learn

  1. str_detect(): Use this inside filter() for finding partial matches on character strings. For example: people %>% filter(str_detect(name, "Amy")) finds everyone named Amy.

  2. left_join(): Use this to combine two tibbles by their keys. For example: people %>% left_join(drivers_license, join_by(license_id == id)). Figure out what to join_by by following the arrows in the schema.

Downloads and Autograder

Here’s the classwork (download R script).

Here’s the autograder. It will provide hints and give you a completion pdf to download at the end.