1. Import your data

Import two related datasets from TidyTuesday Project.

survivalists <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-01-24/survivalists.csv')
## Rows: 94 Columns: 16
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): name, gender, city, state, country, reason_tapped_out, reason_cate...
## dbl  (5): season, age, result, days_lasted, day_linked_up
## lgl  (1): medically_evacuated
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
loadouts <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-01-24/loadouts.csv')
## Rows: 940 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): version, name, item_detailed, item
## dbl (2): season, item_number
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

2. Make data small

Describe the two datasets:

Data1: Survivalist

Data 2: Loadouts

survivalists_small <- survivalists %>% select(season, name, age) %>% sample_n(10)
loadouts_small <- loadouts %>% select(season, name, item_detailed) %>% sample_n(10)

survivalists_small
## # A tibble: 10 × 3
##    season name              age
##     <dbl> <chr>           <dbl>
##  1      5 Britt Ahart        41
##  2      2 Randy Champagne    28
##  3      8 Biko Wright        29
##  4      6 Brady Nicholls     36
##  5      5 Jesse Bosdell      32
##  6      5 Larry Roberts      46
##  7      3 Jim Shields        37
##  8      3 Dave Nessia        49
##  9      4 Pete Brockdorff    61
## 10      2 Nicole Apelian     45
loadouts_small
## # A tibble: 10 × 3
##    season name               item_detailed          
##     <dbl> <chr>              <chr>                  
##  1      5 Sam Larson         Food ration            
##  2      7 Kielyn Marrone     Ferro rod              
##  3      5 Brad Richardson    Axe                    
##  4      6 Nikki van Schyndel Sleeping bag           
##  5      1 Lucas Miller       Extra emergency rations
##  6      4 Brad Richardson    Canteen – 64 oz.       
##  7      9 Tom Garstang       Trapping wire          
##  8      3 Megan Hanacek      Bivvy Bag              
##  9      3 Britt Ahart        Trapping wire          
## 10      5 Brad Richardson    Fishing line and hooks

3. inner_join

Describe the resulting data:

How is it different from the original two datasets?

result <- inner_join(survivalists, loadouts, by = "season")
## Warning in inner_join(survivalists, loadouts, by = "season"): Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
##   "many-to-many"` to silence this warning.

4. left_join

Describe the resulting data:

How is it different from the original two datasets?

result <- left_join(survivalists, loadouts, by = "season")
## Warning in left_join(survivalists, loadouts, by = "season"): Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
##   "many-to-many"` to silence this warning.

5. right_join

Describe the resulting data:

How is it different from the original two datasets?

result <- right_join(survivalists, loadouts, by = "name")
## Warning in right_join(survivalists, loadouts, by = "name"): Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 91 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
##   "many-to-many"` to silence this warning.

6. full_join

Describe the resulting data:

How is it different from the original two datasets?

result <- full_join(survivalists, loadouts, by = "season")
## Warning in full_join(survivalists, loadouts, by = "season"): Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
##   "many-to-many"` to silence this warning.

7. semi_join

Describe the resulting data:

How is it different from the original two datasets?

result <- survivalists %>%
  semi_join(loadouts, by = "name")

8. anti_join

Describe the resulting data:

How is it different from the original two datasets?

result <- anti_join(survivalists, loadouts, by = "name")