1. Import your data

Import two related datasets from TidyTuesday Project.

ufo_sightings <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2023/2023-06-20/ufo_sightings.csv')
## Rows: 96429 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (7): city, state, country_code, shape, reported_duration, summary, day_...
## dbl  (1): duration_seconds
## lgl  (1): has_images
## dttm (2): reported_date_time, reported_date_time_utc
## date (1): posted_date
## 
## ℹ 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.
places <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2023/2023-06-20/places.csv')
## Rows: 14417 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (6): city, alternate_city_names, state, country, country_code, timezone
## dbl (4): latitude, longitude, population, elevation_m
## 
## ℹ 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: UfoSightings

Data 2: Places

set.seed(1234)
ufo_sightings_small <- ufo_sightings %>% select(city, state, shape) %>% sample_n(10)
places_small <- places %>% select(city, state, country_code)

ufo_sightings_small
## # A tibble: 10 × 3
##    city        state shape   
##    <chr>       <chr> <chr>   
##  1 Minneapolis MN    light   
##  2 Danville    CA    circle  
##  3 Avon        NY    fireball
##  4 Glendale    AZ    triangle
##  5 Mayville    NY    teardrop
##  6 Dallas      TX    triangle
##  7 Mount Horeb WI    other   
##  8 Scarborough ME    orb     
##  9 Phoenix     AZ    other   
## 10 Slocomb     AL    circle
places_small
## # A tibble: 14,417 × 3
##    city        state           country_code
##    <chr>       <chr>           <chr>       
##  1 Pinehurst   NC              US          
##  2 Rapid City  MI              US          
##  3 Cleveland   OH              US          
##  4 Bloomington IN              US          
##  5 Irvine      CA              US          
##  6 Moore       OK              US          
##  7 Short Pump  VA              US          
##  8 Norwalk     CT              US          
##  9 Blayney     New South Wales AU          
## 10 Greybull    WY              US          
## # ℹ 14,407 more rows

3. inner_join

Describe the resulting data:

How is it different from the original two datasets? 11 rows compared to the 10 in the original data set

ufo_sightings_small %>% left_join(places_small, by = c("city", "state"))
## # A tibble: 11 × 4
##    city        state shape    country_code
##    <chr>       <chr> <chr>    <chr>       
##  1 Minneapolis MN    light    US          
##  2 Danville    CA    circle   US          
##  3 Avon        NY    fireball US          
##  4 Glendale    AZ    triangle US          
##  5 Glendale    AZ    triangle US          
##  6 Mayville    NY    teardrop US          
##  7 Dallas      TX    triangle US          
##  8 Mount Horeb WI    other    US          
##  9 Scarborough ME    orb      US          
## 10 Phoenix     AZ    other    US          
## 11 Slocomb     AL    circle   US

4. left_join

Describe the resulting data:

How is it different from the original two datasets? it shared the 11 rows with the second but does not share the same 10 rows as the first.

ufo_sightings_small %>% right_join(places_small, by = c("city", "state"))
## # A tibble: 14,417 × 4
##    city        state shape    country_code
##    <chr>       <chr> <chr>    <chr>       
##  1 Minneapolis MN    light    US          
##  2 Danville    CA    circle   US          
##  3 Avon        NY    fireball US          
##  4 Glendale    AZ    triangle US          
##  5 Glendale    AZ    triangle US          
##  6 Mayville    NY    teardrop US          
##  7 Dallas      TX    triangle US          
##  8 Mount Horeb WI    other    US          
##  9 Scarborough ME    orb      US          
## 10 Phoenix     AZ    other    US          
## # ℹ 14,407 more rows

5. right_join

Describe the resulting data:

How is it different from the original two datasets? Way more rows than the original two data sets. this pulled all the original data from the dataset.

ufo_sightings_small %>% inner_join(places_small, by = c("city", "state"))
## # A tibble: 11 × 4
##    city        state shape    country_code
##    <chr>       <chr> <chr>    <chr>       
##  1 Minneapolis MN    light    US          
##  2 Danville    CA    circle   US          
##  3 Avon        NY    fireball US          
##  4 Glendale    AZ    triangle US          
##  5 Glendale    AZ    triangle US          
##  6 Mayville    NY    teardrop US          
##  7 Dallas      TX    triangle US          
##  8 Mount Horeb WI    other    US          
##  9 Scarborough ME    orb      US          
## 10 Phoenix     AZ    other    US          
## 11 Slocomb     AL    circle   US

6. full_join

Describe the resulting data:

How is it different from the original two datasets? this had all the rows of the orignal dataset so this was very different from the first two origninal

ufo_sightings_small %>%
  full_join(places_small, by = c("city", "state"))
## # A tibble: 14,417 × 4
##    city        state shape    country_code
##    <chr>       <chr> <chr>    <chr>       
##  1 Minneapolis MN    light    US          
##  2 Danville    CA    circle   US          
##  3 Avon        NY    fireball US          
##  4 Glendale    AZ    triangle US          
##  5 Glendale    AZ    triangle US          
##  6 Mayville    NY    teardrop US          
##  7 Dallas      TX    triangle US          
##  8 Mount Horeb WI    other    US          
##  9 Scarborough ME    orb      US          
## 10 Phoenix     AZ    other    US          
## # ℹ 14,407 more rows

7. semi_join

Describe the resulting data:

How is it different from the original two datasets? This showed more similarity to the first dataset where there were 10 rows but eliminated the fourth column

ufo_sightings_small %>%
  semi_join(places_small, by = c("city", "state"))
## # A tibble: 10 × 3
##    city        state shape   
##    <chr>       <chr> <chr>   
##  1 Minneapolis MN    light   
##  2 Danville    CA    circle  
##  3 Avon        NY    fireball
##  4 Glendale    AZ    triangle
##  5 Mayville    NY    teardrop
##  6 Dallas      TX    triangle
##  7 Mount Horeb WI    other   
##  8 Scarborough ME    orb     
##  9 Phoenix     AZ    other   
## 10 Slocomb     AL    circle

8. anti_join

Describe the resulting data:

How is it different from the original two datasets? this was very different from the original data set since there was no rows at all after the code was ran

ufo_sightings_small %>%
  anti_join(places_small, by = c("city", "state"))
## # A tibble: 0 × 3
## # ℹ 3 variables: city <chr>, state <chr>, shape <chr>