Import two related datasets from TidyTuesday Project.
taylor_album_songs <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-10-17/taylor_album_songs.csv')
## Rows: 194 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (7): album_name, track_name, artist, featuring, key_name, mode_name, k...
## dbl (14): track_number, danceability, energy, key, loudness, mode, speechin...
## lgl (4): ep, bonus_track, explicit, lyrics
## date (4): album_release, promotional_release, single_release, track_release
##
## ℹ 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.
taylor_all_songs <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-10-17/taylor_all_songs.csv')
## Rows: 274 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (7): album_name, track_name, artist, featuring, key_name, mode_name, k...
## dbl (14): track_number, danceability, energy, key, loudness, mode, speechin...
## lgl (4): ep, bonus_track, explicit, lyrics
## date (4): album_release, promotional_release, single_release, track_release
##
## ℹ 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.
Describe the two datasets:
Data1: Taylor album songs
Data 2: Taylor all songs
set.seed(1234)
taylor_album_songs_small <- taylor_album_songs %>% select(album_name, track_name, key_mode) %>% sample_n(10)
taylor_all_songs_small <- taylor_all_songs %>% select(album_name, track_name, duration_ms) %>% sample_n(10)
taylor_all_songs_small
## # A tibble: 10 × 3
## album_name track_name duration_ms
## <chr> <chr> <dbl>
## 1 Red Red (Original Demo Recording) 226280
## 2 Red (Taylor's Version) I Knew You Were Trouble (Taylor's Ve… 219760
## 3 Midnights Maroon 218271
## 4 Red The Lucky One 240133
## 5 Red Red 220827
## 6 folklore mirrorball 208973
## 7 Speak Now Sparks Fly 260933
## 8 Taylor Swift A Place In This World 199200
## 9 reputation Don't Blame Me 236413
## 10 Fearless (Taylor's Version) You Belong With Me (Taylor's Version) 231124
taylor_album_songs_small
## # A tibble: 10 × 3
## album_name track_name key_mode
## <chr> <chr> <chr>
## 1 Fearless (Taylor's Version) Change (Taylor's Version) F major
## 2 Red (Taylor's Version) Better Man (Taylor's Version) [From The… E major
## 3 folklore epiphany C# major
## 4 1989 Clean E major
## 5 reputation So It Goes... D major
## 6 Lover Daylight C major
## 7 Lover You Need To Calm Down D major
## 8 evermore long story short C major
## 9 folklore seven E major
## 10 Lover False God B minor
Describe the resulting data:
How is it different from the original two datasets? * The small data sets have 10 rows each and the inner join data returned 0 rows * The resulting joined data combined the columns album name and track name and added unique columns of key mode and duration
taylor_album_songs_small %>% inner_join(taylor_all_songs_small, by = c("album_name", "track_name"))
## # A tibble: 0 × 4
## # ℹ 4 variables: album_name <chr>, track_name <chr>, key_mode <chr>,
## # duration_ms <dbl>
Describe the resulting data:
How is it different from the original two datasets? * The original data sets have 3 columns each and this data set has 4 columns * The observations are now in the taylor_album_songs_small dataset and have added a column of duration which has NA values
taylor_album_songs_small %>% left_join(taylor_all_songs_small)
## Joining with `by = join_by(album_name, track_name)`
## # A tibble: 10 × 4
## album_name track_name key_mode duration_ms
## <chr> <chr> <chr> <dbl>
## 1 Fearless (Taylor's Version) Change (Taylor's Version) F major NA
## 2 Red (Taylor's Version) Better Man (Taylor's Versio… E major NA
## 3 folklore epiphany C# major NA
## 4 1989 Clean E major NA
## 5 reputation So It Goes... D major NA
## 6 Lover Daylight C major NA
## 7 Lover You Need To Calm Down D major NA
## 8 evermore long story short C major NA
## 9 folklore seven E major NA
## 10 Lover False God B minor NA
Describe the resulting data:
How is it different from the original two datasets?
taylor_album_songs_small %>% right_join(taylor_all_songs_small)
## Joining with `by = join_by(album_name, track_name)`
## # A tibble: 10 × 4
## album_name track_name key_mode duration_ms
## <chr> <chr> <chr> <dbl>
## 1 Red Red (Original Demo Recordin… <NA> 226280
## 2 Red (Taylor's Version) I Knew You Were Trouble (Ta… <NA> 219760
## 3 Midnights Maroon <NA> 218271
## 4 Red The Lucky One <NA> 240133
## 5 Red Red <NA> 220827
## 6 folklore mirrorball <NA> 208973
## 7 Speak Now Sparks Fly <NA> 260933
## 8 Taylor Swift A Place In This World <NA> 199200
## 9 reputation Don't Blame Me <NA> 236413
## 10 Fearless (Taylor's Version) You Belong With Me (Taylor'… <NA> 231124
Describe the resulting data:
How is it different from the original two datasets?
taylor_album_songs_small %>% full_join(taylor_all_songs_small)
## Joining with `by = join_by(album_name, track_name)`
## # A tibble: 20 × 4
## album_name track_name key_mode duration_ms
## <chr> <chr> <chr> <dbl>
## 1 Fearless (Taylor's Version) Change (Taylor's Version) F major NA
## 2 Red (Taylor's Version) Better Man (Taylor's Versio… E major NA
## 3 folklore epiphany C# major NA
## 4 1989 Clean E major NA
## 5 reputation So It Goes... D major NA
## 6 Lover Daylight C major NA
## 7 Lover You Need To Calm Down D major NA
## 8 evermore long story short C major NA
## 9 folklore seven E major NA
## 10 Lover False God B minor NA
## 11 Red Red (Original Demo Recordin… <NA> 226280
## 12 Red (Taylor's Version) I Knew You Were Trouble (Ta… <NA> 219760
## 13 Midnights Maroon <NA> 218271
## 14 Red The Lucky One <NA> 240133
## 15 Red Red <NA> 220827
## 16 folklore mirrorball <NA> 208973
## 17 Speak Now Sparks Fly <NA> 260933
## 18 Taylor Swift A Place In This World <NA> 199200
## 19 reputation Don't Blame Me <NA> 236413
## 20 Fearless (Taylor's Version) You Belong With Me (Taylor'… <NA> 231124
Describe the resulting data:
How is it different from the original two datasets?
taylor_album_songs_small %>% semi_join(taylor_all_songs_small)
## Joining with `by = join_by(album_name, track_name)`
## # A tibble: 0 × 3
## # ℹ 3 variables: album_name <chr>, track_name <chr>, key_mode <chr>
taylor_all_songs_small %>% semi_join(taylor_album_songs_small)
## Joining with `by = join_by(album_name, track_name)`
## # A tibble: 0 × 3
## # ℹ 3 variables: album_name <chr>, track_name <chr>, duration_ms <dbl>
Describe the resulting data:
How is it different from the original two datasets?
taylor_album_songs_small %>% anti_join(taylor_all_songs_small)
## Joining with `by = join_by(album_name, track_name)`
## # A tibble: 10 × 3
## album_name track_name key_mode
## <chr> <chr> <chr>
## 1 Fearless (Taylor's Version) Change (Taylor's Version) F major
## 2 Red (Taylor's Version) Better Man (Taylor's Version) [From The… E major
## 3 folklore epiphany C# major
## 4 1989 Clean E major
## 5 reputation So It Goes... D major
## 6 Lover Daylight C major
## 7 Lover You Need To Calm Down D major
## 8 evermore long story short C major
## 9 folklore seven E major
## 10 Lover False God B minor
taylor_all_songs_small %>% anti_join(taylor_album_songs_small)
## Joining with `by = join_by(album_name, track_name)`
## # A tibble: 10 × 3
## album_name track_name duration_ms
## <chr> <chr> <dbl>
## 1 Red Red (Original Demo Recording) 226280
## 2 Red (Taylor's Version) I Knew You Were Trouble (Taylor's Ve… 219760
## 3 Midnights Maroon 218271
## 4 Red The Lucky One 240133
## 5 Red Red 220827
## 6 folklore mirrorball 208973
## 7 Speak Now Sparks Fly 260933
## 8 Taylor Swift A Place In This World 199200
## 9 reputation Don't Blame Me 236413
## 10 Fearless (Taylor's Version) You Belong With Me (Taylor's Version) 231124