1. Import your data

Import two related datasets from TidyTuesday Project.

haunted <- read.csv("../00_data/MyData.csv")

2. Make data small

Describe the two datasets:

Data1

Data 2

3. inner_join

Describe the resulting data:

How is it different from the original two datasets?

x <- tribble(
  ~key, ~val_x,
     1, "x1",
     2, "x2",
     3, "x3"
)
y <- tribble(
  ~key, ~val_y,
     1, "y1",
     2, "y2",
     4, "y3"
)

inner_join(x, y)
## Joining with `by = join_by(key)`
## # A tibble: 2 × 3
##     key val_x val_y
##   <dbl> <chr> <chr>
## 1     1 x1    y1   
## 2     2 x2    y2

4. left_join

Describe the resulting data:

How is it different from the original two datasets?

left_join(x, y)
## Joining with `by = join_by(key)`
## # A tibble: 3 × 3
##     key val_x val_y
##   <dbl> <chr> <chr>
## 1     1 x1    y1   
## 2     2 x2    y2   
## 3     3 x3    <NA>
right_join(x, y)
## Joining with `by = join_by(key)`
## # A tibble: 3 × 3
##     key val_x val_y
##   <dbl> <chr> <chr>
## 1     1 x1    y1   
## 2     2 x2    y2   
## 3     4 <NA>  y3
full_join(x, y)
## Joining with `by = join_by(key)`
## # A tibble: 4 × 3
##     key val_x val_y
##   <dbl> <chr> <chr>
## 1     1 x1    y1   
## 2     2 x2    y2   
## 3     3 x3    <NA> 
## 4     4 <NA>  y3

5. right_join

Describe the resulting data:

How is it different from the original two datasets?

6. full_join

Describe the resulting data:

How is it different from the original two datasets?

7. semi_join

Describe the resulting data:

How is it different from the original two datasets?

8. anti_join

Describe the resulting data:

How is it different from the original two datasets?