Author
Published

Monday, January 13, 2025

I’m so happy to announce the release of taylor 3.2.0. taylor provides data on Taylor Swift’s discography, including lyrics from Genius and song characteristics from Spotify.

You can install the updated version from CRAN with:

This is a minor release to update the package following the end of The Eras Tour. This blog post will highlight the changes in this release.

It’s the end of an Era…

The primary update completion of the eras_tour_surprise data to include surprise songs from the European and final North American legs of The Eras Tour. You can now find all surprise songs in eras_tour_surprise.

library(tidyverse)

eras_tour_surprise %>% 
  filter(leg == "Europe")
#> # A tibble: 96 × 9
#>    leg    date       city              night dress instrument song  mashup guest
#>    <chr>  <date>     <chr>             <int> <chr> <chr>      <chr> <chr>  <chr>
#>  1 Europe 2024-05-09 Paris, France         1 brig… guitar     Paris <NA>   <NA> 
#>  2 Europe 2024-05-09 Paris, France         1 brig… piano      loml  <NA>   <NA> 
#>  3 Europe 2024-05-10 Paris, France         2 ocea… guitar     Is I… Out O… <NA> 
#>  4 Europe 2024-05-10 Paris, France         2 ocea… piano      My B… <NA>   <NA> 
#>  5 Europe 2024-05-11 Paris, France         3 suns… guitar     Hey … <NA>   <NA> 
#>  6 Europe 2024-05-11 Paris, France         3 suns… piano      Maro… <NA>   <NA> 
#>  7 Europe 2024-05-12 Paris, France         4 ocea… guitar     The … Treac… <NA> 
#>  8 Europe 2024-05-12 Paris, France         4 ocea… piano      Begi… Paris  <NA> 
#>  9 Europe 2024-05-17 Stockholm, Sweden     1 brig… guitar     I Th… Gorge… <NA> 
#> 10 Europe 2024-05-17 Stockholm, Sweden     1 brig… piano      Peter <NA>   <NA> 
#> # ℹ 86 more rows

eras_tour_surprise %>% 
  filter(leg == "North America (Leg 2)")
#> # A tibble: 36 × 9
#>    leg                date       city  night dress instrument song  mashup guest
#>    <chr>              <date>     <chr> <int> <chr> <chr>      <chr> <chr>  <chr>
#>  1 North America (Le… 2024-10-18 Miam…     1 bett… guitar     Tim … Timel… <NA> 
#>  2 North America (Le… 2024-10-18 Miam…     1 bett… piano      this… Dayli… <NA> 
#>  3 North America (Le… 2024-10-19 Miam…     2 supe… guitar     Shou… I Did… <NA> 
#>  4 North America (Le… 2024-10-19 Miam…     2 supe… piano      loml  White… <NA> 
#>  5 North America (Le… 2024-10-20 Miam…     3 sunr… guitar     Out … All Y… <NA> 
#>  6 North America (Le… 2024-10-20 Miam…     3 sunr… piano      mirr… Guilt… <NA> 
#>  7 North America (Le… 2024-10-25 New …     1 koi … guitar     Our … Call … <NA> 
#>  8 North America (Le… 2024-10-25 New …     1 koi … piano      The … Haunt… <NA> 
#>  9 North America (Le… 2024-10-26 New …     2 suns… guitar     Espr… Is It… Sabr…
#> 10 North America (Le… 2024-10-26 New …     2 suns… piano      Hits… Welco… <NA> 
#> # ℹ 26 more rows

Using this data, we can, for example, look at the cumulative number of songs Taylor performed from each album over the course of the tour.

Plot code
leg_labels <- unique(eras_tour_surprise$leg)
leg_labels <- gsub("South America", "South\nAmerica", leg_labels)

surprise_song_count <- eras_tour_surprise %>%
  nest(dat = -c(leg, date, city, night)) %>%
  arrange(date) %>%
  mutate(leg = factor(leg, levels = unique(eras_tour_surprise$leg),
                      labels = leg_labels)) %>%
  mutate(show_number = seq_len(n()), .after = night) %>%
  unnest(dat) %>%
  left_join(distinct(taylor_album_songs, track_name, album_name),
            join_by(song == track_name),
            relationship = "many-to-one") %>%
  count(leg, date, city, night, show_number, album_name) %>%
  complete(nesting(leg, date, city, night, show_number), album_name) %>%
  mutate(n = replace_na(n, 0)) %>%
  arrange(album_name, date, night) %>%
  mutate(surprise_count = cumsum(n), .by = album_name) %>%
  left_join(select(taylor_albums, album_name, album_release),
            by = "album_name") %>%
  mutate(surprise_count = case_when(
    album_name == "THE TORTURED POETS DEPARTMENT" &
      date < album_release ~ NA_integer_,
    .default = surprise_count
  )) %>%
  add_row(leg = factor("Europe"), album_name = "THE TORTURED POETS DEPARTMENT",
          show_number = 83.5, surprise_count = 0L) %>%
  mutate(album_name = replace_na(album_name, "Other"),
         album_group = album_name,
         album_name = factor(album_name, c(album_levels, "Other"),
                             labels = c(gsub("POETS DEPARTMENT",
                                             "POETS<br>DEPARTMENT",
                                             album_levels), "Other")))

ggplot(surprise_song_count) +
  facet_wrap(~ album_name, ncol = 3, axes = "all_x") +
  geom_line(data = ~select(.x, -album_name),
            aes(x = show_number, y = surprise_count, group = album_group),
            color = "grey80", na.rm = TRUE) +
  geom_line(aes(x = show_number, y = surprise_count, color = album_group),
            show.legend = FALSE, linewidth = 2, na.rm = TRUE) +
  scale_color_albums(na.value = "grey80") +
  scale_x_continuous(breaks = c(1, seq(30, 200, 30))) +
  labs(x = "Show", y = "Songs Played")

A horizontal bar graph showing track names on the y-axis and song energey on the x-axis. Bars a filled with colors derived from the TTPD color palette, ranging from a light grey to black.

Finally, also inspired by some of Taylor’s surprise song choices, taylor_all_songs has been updated to include songs Taylor wrote, but is not the performer (e.g., “This is What You Came For” by Calvin Harris, featuring Rihanna).

taylor_all_songs |> 
  filter(!str_detect(artist, "Taylor Swift"),
         is.na(featuring) | !str_detect(featuring, "Taylor Swift"))
#> # A tibble: 7 × 29
#>   album_name ep    album_release track_number track_name        artist featuring
#>   <chr>      <lgl> <date>               <int> <chr>             <chr>  <chr>    
#> 1 <NA>       NA    NA                      NA 1 step forward, … "Oliv… <NA>     
#> 2 <NA>       NA    NA                      NA Best Days Of You… "Kell… <NA>     
#> 3 <NA>       NA    NA                      NA Better Man        "Litt… <NA>     
#> 4 <NA>       NA    NA                      NA deja vu           "Oliv… <NA>     
#> 5 <NA>       NA    NA                      NA This Is What You… "Calv… Rihanna  
#> 6 <NA>       NA    NA                      NA TMZ               "\"We… <NA>     
#> 7 <NA>       NA    NA                      NA You'll Always Fi… "Hann… <NA>     
#> # ℹ 22 more variables: bonus_track <lgl>, promotional_release <date>,
#> #   single_release <date>, track_release <date>, danceability <dbl>,
#> #   energy <dbl>, key <int>, loudness <dbl>, mode <int>, speechiness <dbl>,
#> #   acousticness <dbl>, instrumentalness <dbl>, liveness <dbl>, valence <dbl>,
#> #   tempo <dbl>, time_signature <int>, duration_ms <int>, explicit <lgl>,
#> #   key_name <chr>, mode_name <chr>, key_mode <chr>, lyrics <list>

Minor Changes

There were also a couple of minor improvements:

  • Error messages and color palette displays have been improved thanks to @olivroy
  • Spotify data for “Half Of My Heart” has been removed, as the version featuring Taylor Swift is no longer available.

For a complete list of changes, check out the changelog.

Acknowledgments

Featured photo by Myriam Zilles on Unsplash. m