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: Survivalists

Data 2: Loadouts

set.seed(1234)
survivalist_small <- survivalists %>% select(season, name, age) %>% sample_n(10)
loadouts_small    <- loadouts %>% select(season, name, item_detailed) %>% sample_n(10)

survivalist_small
## # A tibble: 10 × 3
##    season name                 age
##     <dbl> <chr>              <dbl>
##  1      3 Britt Ahart           40
##  2      8 Nate Weber            47
##  3      3 Carleigh Fairchild    28
##  4      1 Chris Weatherman      41
##  5      1 Dustin Feher          37
##  6      4 Brody Wilkes          33
##  7      2 Randy Champagne       28
##  8      1 Lucas Miller          32
##  9      9 Karie Lee Knoke       57
## 10      7 Joe Nicholas          31
loadouts_small
## # A tibble: 10 × 3
##    season name             item_detailed                                        
##     <dbl> <chr>            <chr>                                                
##  1      1 Chris Weatherman Knife                                                
##  2      9 Jessie Krebs     Trapping wire                                        
##  3      3 Jim Shields      Rations                                              
##  4      4 Shannon Bosdell  Tarp – 12′ x 12′                                     
##  5      2 Nicole Apelian   200 yards of 30 lb test fishing line, 100 yards of 8…
##  6      6 Barry Karcher    Saw                                                  
##  7      1 Alan Kay         Large 2-quart pot                                    
##  8      9 Tom Garstang     Folding Saw                                          
##  9      7 Kielyn Marrone   Snare wire                                           
## 10      6 Woniya Thibeault Pot

3. inner_join

Describe the resulting data:

How is it different from the original two datasets?

survivalist_small %>% inner_join(loadouts_small, by = c("season", "name"))
## # A tibble: 1 × 4
##   season name               age item_detailed
##    <dbl> <chr>            <dbl> <chr>        
## 1      1 Chris Weatherman    41 Knife

4. left_join

Describe the resulting data:

How is it different from the original two datasets?

survivalist_small %>% left_join(loadouts_small, by = c("season", "name"))
## # A tibble: 10 × 4
##    season name                 age item_detailed
##     <dbl> <chr>              <dbl> <chr>        
##  1      3 Britt Ahart           40 <NA>         
##  2      8 Nate Weber            47 <NA>         
##  3      3 Carleigh Fairchild    28 <NA>         
##  4      1 Chris Weatherman      41 Knife        
##  5      1 Dustin Feher          37 <NA>         
##  6      4 Brody Wilkes          33 <NA>         
##  7      2 Randy Champagne       28 <NA>         
##  8      1 Lucas Miller          32 <NA>         
##  9      9 Karie Lee Knoke       57 <NA>         
## 10      7 Joe Nicholas          31 <NA>

5. right_join

Describe the resulting data:

How is it different from the original two datasets?

survivalist_small %>% right_join(loadouts_small, by = c("season", "name"))
## # A tibble: 10 × 4
##    season name               age item_detailed                                  
##     <dbl> <chr>            <dbl> <chr>                                          
##  1      1 Chris Weatherman    41 Knife                                          
##  2      9 Jessie Krebs        NA Trapping wire                                  
##  3      3 Jim Shields         NA Rations                                        
##  4      4 Shannon Bosdell     NA Tarp – 12′ x 12′                               
##  5      2 Nicole Apelian      NA 200 yards of 30 lb test fishing line, 100 yard…
##  6      6 Barry Karcher       NA Saw                                            
##  7      1 Alan Kay            NA Large 2-quart pot                              
##  8      9 Tom Garstang        NA Folding Saw                                    
##  9      7 Kielyn Marrone      NA Snare wire                                     
## 10      6 Woniya Thibeault    NA Pot

6. full_join

Describe the resulting data:

How is it different from the original two datasets?

survivalist_small %>% 
    full_join(loadouts_small, by = c("season", "name"))
## # A tibble: 19 × 4
##    season name                 age item_detailed                                
##     <dbl> <chr>              <dbl> <chr>                                        
##  1      3 Britt Ahart           40 <NA>                                         
##  2      8 Nate Weber            47 <NA>                                         
##  3      3 Carleigh Fairchild    28 <NA>                                         
##  4      1 Chris Weatherman      41 Knife                                        
##  5      1 Dustin Feher          37 <NA>                                         
##  6      4 Brody Wilkes          33 <NA>                                         
##  7      2 Randy Champagne       28 <NA>                                         
##  8      1 Lucas Miller          32 <NA>                                         
##  9      9 Karie Lee Knoke       57 <NA>                                         
## 10      7 Joe Nicholas          31 <NA>                                         
## 11      9 Jessie Krebs          NA Trapping wire                                
## 12      3 Jim Shields           NA Rations                                      
## 13      4 Shannon Bosdell       NA Tarp – 12′ x 12′                             
## 14      2 Nicole Apelian        NA 200 yards of 30 lb test fishing line, 100 ya…
## 15      6 Barry Karcher         NA Saw                                          
## 16      1 Alan Kay              NA Large 2-quart pot                            
## 17      9 Tom Garstang          NA Folding Saw                                  
## 18      7 Kielyn Marrone        NA Snare wire                                   
## 19      6 Woniya Thibeault      NA Pot

7. semi_join

Describe the resulting data:

How is it different from the original two datasets?

survivalist_small %>% 
    semi_join(loadouts_small, by = c("season", "name"))
## # A tibble: 1 × 3
##   season name               age
##    <dbl> <chr>            <dbl>
## 1      1 Chris Weatherman    41

8. anti_join

Describe the resulting data:

How is it different from the original two datasets?

survivalist_small %>% 
    anti_join(loadouts_small, by = c("season", "name"))
## # A tibble: 9 × 3
##   season name                 age
##    <dbl> <chr>              <dbl>
## 1      3 Britt Ahart           40
## 2      8 Nate Weber            47
## 3      3 Carleigh Fairchild    28
## 4      1 Dustin Feher          37
## 5      4 Brody Wilkes          33
## 6      2 Randy Champagne       28
## 7      1 Lucas Miller          32
## 8      9 Karie Lee Knoke       57
## 9      7 Joe Nicholas          31