class: inverse, left, bottom background-image: url(https://images.unsplash.com/photo-1601312378427-822b2b41da35?auto=format&fit=crop&q=80&w=1548&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D) background-size: cover # .Large[#'tswift keys' featurette] ## .small[featuring [{ggbarlabs}](https://github.com/everyday_analytics/ggbarlabs) which is experimental] #### .tiny[Gina Reynolds | 2023-10-26 |Image credit: David Pisnoy, Upsplash] ??? Title --- # What keys does Taylor Swift write in the most? --- -- **key**: The estimated overall key of the track. Integers map to pitches using standard Pitch Class notation . E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on. If no key was detected, the value is -1. --- ```r library(tidyverse) taylor_album_songs <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-10-17/taylor_album_songs.csv') ``` --- class: inverse, middle, center # featured: ggbarlabs:::geom_barlab_count_percent --- count: false .panel1-feature-auto[ ```r *taylor_album_songs ``` ] .panel2-feature-auto[ ``` ## # A tibble: 194 × 29 ## album_name ep album_release track_number track_name artist featuring ## <chr> <lgl> <date> <dbl> <chr> <chr> <chr> ## 1 Taylor Swift FALSE 2006-10-24 1 Tim McGraw Taylo… <NA> ## 2 Taylor Swift FALSE 2006-10-24 2 Picture To Bu… Taylo… <NA> ## 3 Taylor Swift FALSE 2006-10-24 3 Teardrops On … Taylo… <NA> ## 4 Taylor Swift FALSE 2006-10-24 4 A Place In Th… Taylo… <NA> ## 5 Taylor Swift FALSE 2006-10-24 5 Cold As You Taylo… <NA> ## 6 Taylor Swift FALSE 2006-10-24 6 The Outside Taylo… <NA> ## 7 Taylor Swift FALSE 2006-10-24 7 Tied Together… Taylo… <NA> ## 8 Taylor Swift FALSE 2006-10-24 8 Stay Beautiful Taylo… <NA> ## 9 Taylor Swift FALSE 2006-10-24 9 Should've Sai… Taylo… <NA> ## 10 Taylor Swift FALSE 2006-10-24 10 Mary's Song (… Taylo… <NA> ## # ℹ 184 more rows ## # ℹ 22 more variables: bonus_track <lgl>, promotional_release <date>, ## # single_release <date>, track_release <date>, danceability <dbl>, ## # energy <dbl>, key <dbl>, loudness <dbl>, mode <dbl>, speechiness <dbl>, ## # acousticness <dbl>, instrumentalness <dbl>, liveness <dbl>, valence <dbl>, ## # tempo <dbl>, time_signature <dbl>, duration_ms <dbl>, explicit <lgl>, ## # key_name <chr>, mode_name <chr>, key_mode <chr>, lyrics <lgl> ``` ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% * mutate(key_name = ifelse(mode, key_name, tolower(key_name))) ``` ] .panel2-feature-auto[ ``` ## # A tibble: 194 × 29 ## album_name ep album_release track_number track_name artist featuring ## <chr> <lgl> <date> <dbl> <chr> <chr> <chr> ## 1 Taylor Swift FALSE 2006-10-24 1 Tim McGraw Taylo… <NA> ## 2 Taylor Swift FALSE 2006-10-24 2 Picture To Bu… Taylo… <NA> ## 3 Taylor Swift FALSE 2006-10-24 3 Teardrops On … Taylo… <NA> ## 4 Taylor Swift FALSE 2006-10-24 4 A Place In Th… Taylo… <NA> ## 5 Taylor Swift FALSE 2006-10-24 5 Cold As You Taylo… <NA> ## 6 Taylor Swift FALSE 2006-10-24 6 The Outside Taylo… <NA> ## 7 Taylor Swift FALSE 2006-10-24 7 Tied Together… Taylo… <NA> ## 8 Taylor Swift FALSE 2006-10-24 8 Stay Beautiful Taylo… <NA> ## 9 Taylor Swift FALSE 2006-10-24 9 Should've Sai… Taylo… <NA> ## 10 Taylor Swift FALSE 2006-10-24 10 Mary's Song (… Taylo… <NA> ## # ℹ 184 more rows ## # ℹ 22 more variables: bonus_track <lgl>, promotional_release <date>, ## # single_release <date>, track_release <date>, danceability <dbl>, ## # energy <dbl>, key <dbl>, loudness <dbl>, mode <dbl>, speechiness <dbl>, ## # acousticness <dbl>, instrumentalness <dbl>, liveness <dbl>, valence <dbl>, ## # tempo <dbl>, time_signature <dbl>, duration_ms <dbl>, explicit <lgl>, ## # key_name <chr>, mode_name <chr>, key_mode <chr>, lyrics <lgl> ``` ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% * filter(!is.na(key_mode)) ``` ] .panel2-feature-auto[ ``` ## # A tibble: 191 × 29 ## album_name ep album_release track_number track_name artist featuring ## <chr> <lgl> <date> <dbl> <chr> <chr> <chr> ## 1 Taylor Swift FALSE 2006-10-24 1 Tim McGraw Taylo… <NA> ## 2 Taylor Swift FALSE 2006-10-24 2 Picture To Bu… Taylo… <NA> ## 3 Taylor Swift FALSE 2006-10-24 3 Teardrops On … Taylo… <NA> ## 4 Taylor Swift FALSE 2006-10-24 4 A Place In Th… Taylo… <NA> ## 5 Taylor Swift FALSE 2006-10-24 5 Cold As You Taylo… <NA> ## 6 Taylor Swift FALSE 2006-10-24 6 The Outside Taylo… <NA> ## 7 Taylor Swift FALSE 2006-10-24 7 Tied Together… Taylo… <NA> ## 8 Taylor Swift FALSE 2006-10-24 8 Stay Beautiful Taylo… <NA> ## 9 Taylor Swift FALSE 2006-10-24 9 Should've Sai… Taylo… <NA> ## 10 Taylor Swift FALSE 2006-10-24 10 Mary's Song (… Taylo… <NA> ## # ℹ 181 more rows ## # ℹ 22 more variables: bonus_track <lgl>, promotional_release <date>, ## # single_release <date>, track_release <date>, danceability <dbl>, ## # energy <dbl>, key <dbl>, loudness <dbl>, mode <dbl>, speechiness <dbl>, ## # acousticness <dbl>, instrumentalness <dbl>, liveness <dbl>, valence <dbl>, ## # tempo <dbl>, time_signature <dbl>, duration_ms <dbl>, explicit <lgl>, ## # key_name <chr>, mode_name <chr>, key_mode <chr>, lyrics <lgl> ``` ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% * ggplot() ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_04_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + * aes(x = fct_infreq(key_name)) ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_05_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + * geom_bar(alpha = .8) ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_06_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + geom_bar(alpha = .8) + * aes(fill = ifelse(mode, "major", "minor")) ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_07_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + geom_bar(alpha = .8) + aes(fill = ifelse(mode, "major", "minor")) + * scale_fill_manual(values = c("midnightblue", "magenta")) ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_08_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + geom_bar(alpha = .8) + aes(fill = ifelse(mode, "major", "minor")) + scale_fill_manual(values = c("midnightblue", "magenta")) + * ggbarlabs::geom_barlab_count_percent(size = 3) ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_09_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + geom_bar(alpha = .8) + aes(fill = ifelse(mode, "major", "minor")) + scale_fill_manual(values = c("midnightblue", "magenta")) + ggbarlabs::geom_barlab_count_percent(size = 3) + * labs(title = "What Keys are Taylor Swift's Songs in?", * caption = "In #tidytuesday's 2023-10-17/taylor_album_songs.csv", * subtitle = "Number of Songs in keys from album songs by key") ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_10_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + geom_bar(alpha = .8) + aes(fill = ifelse(mode, "major", "minor")) + scale_fill_manual(values = c("midnightblue", "magenta")) + ggbarlabs::geom_barlab_count_percent(size = 3) + labs(title = "What Keys are Taylor Swift's Songs in?", caption = "In #tidytuesday's 2023-10-17/taylor_album_songs.csv", subtitle = "Number of Songs in keys from album songs by key") + * ggbarlabs::defaults_ggbarlabs() ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_11_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + geom_bar(alpha = .8) + aes(fill = ifelse(mode, "major", "minor")) + scale_fill_manual(values = c("midnightblue", "magenta")) + ggbarlabs::geom_barlab_count_percent(size = 3) + labs(title = "What Keys are Taylor Swift's Songs in?", caption = "In #tidytuesday's 2023-10-17/taylor_album_songs.csv", subtitle = "Number of Songs in keys from album songs by key") + ggbarlabs::defaults_ggbarlabs() + * labs(x = NULL) ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_12_output-1.png" width="80%" /> ] --- count: false .panel1-feature-auto[ ```r taylor_album_songs %>% mutate(key_name = ifelse(mode, key_name, tolower(key_name))) %>% filter(!is.na(key_mode)) %>% ggplot() + aes(x = fct_infreq(key_name)) + geom_bar(alpha = .8) + aes(fill = ifelse(mode, "major", "minor")) + scale_fill_manual(values = c("midnightblue", "magenta")) + ggbarlabs::geom_barlab_count_percent(size = 3) + labs(title = "What Keys are Taylor Swift's Songs in?", caption = "In #tidytuesday's 2023-10-17/taylor_album_songs.csv", subtitle = "Number of Songs in keys from album songs by key") + ggbarlabs::defaults_ggbarlabs() + labs(x = NULL) + * labs(fill = NULL) ``` ] .panel2-feature-auto[ <img src="tswift-keys_files/figure-html/feature_auto_13_output-1.png" width="80%" /> ] <style> .panel1-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-feature-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- <img src="tswift-keys_files/figure-html/feature-1.png" width="80%" style="display: block; margin: auto;" /> --- ### Contribute - https://github.com/everyday-analytics/ggbarlabs --- ### Check out flipbookr, used to build this featurette - https://github.com/EvaMaeRey/flipbookr - discussion: https://github.com/EvaMaeRey/flipbookr/blob/master/docs/draft_jasa_submission.pdf --- ### Check out more featurettes - https://EvaMaeRey.github.io/featurette