Taylor Swift is a common household name with young girls and grown men alike. Coming to the stage in 2006 with her first album, “Taylor Swift,” she made a name for herself as a country star at only sixteen years old. When she transitioned to the pop sphere of music, she rose to success that few ever achieve, her net worth is estimated to be above 360 Million dollars. Taylor Swift rose to fame and stayed in the spotlight because of her lyrics, more specifically her storytelling ability. Her fans love her music because she has the ability to paint a scene with her words and put listeners in the middle of it, feeling the emotions as if they were Taylor themselves. Dubbed the ‘Queen of Breakup Songs’, Swift has made her fair share of heartbreak tunes, as well as coming of age songs, pop ballads, and, more recently, political statements. But other than lyrics, what features do her songs share that help emit the sadness or heartbreak that Swift is trying to convey? Have these features changed as her musical style has?

In this project, I will show the musical ways in which Taylor Swift transitioned from Country to Pop music over her career.


The “country” albums are classified as Swift’s first three albums, Taylor Swift, Speak Now, and Fearless. The “pop” albums are classified as Red, 1989, reputation, and Lover. I decided this classification based on this album list. To determine the difference between her two albums, we first have to define the difference between the “pop” and “country” genre. An article by Vox defines the usual pop song as around 3 minutes, shorter than the average country song. I also hypothesize that pop music would be more danceable, and that different keys would be used for pop versus country songs.

I first had to run the packages and retrieve the songs and lyrics from the Spotify and Genius API

library(devtools)
library(spotifyr)
library(tidyverse)
library(knitr)
library(ggjoy)
library(genius)
library(tidytext)
library(textdata)
library(kableExtra)
devtools::install_github('charlie86/spotifyr')

Sys.setenv(SPOTIFY_CLIENT_ID = '577f9d2eef904e189cd820239d8d5d06')
Sys.setenv(SPOTIFY_CLIENT_SECRET = '8f78a6e887604e26a8b192dd189a0822')

access_token <- get_spotify_access_token()

taylor <- get_artist_audio_features('taylor swift') %>% 
  filter(album_id == "1NAmidJlEaVgA3MpcPFYGq" | album_id == "5eyZZoQEFQWRHkV2xgAeBw" | album_id == "43OpbkiiIxJO8ktIB777Nn" |
           album_id == "5MfAxS5zz8MlfROjGQVXhy" | album_id == "1EoDsNmgTLtmwe1BDAVxV5" |
           album_id == "2QJmrSgbdM35R67eoGQo4j" | album_id == "6DEjYFkNZh67HP7R9PSZvv")
## Warning: `mutate_()` is deprecated as of dplyr 0.7.0.
## Please use `mutate()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.

Then I calculated the average length of a song on the album. Note that the table below is showing the decimal forms of time in minutes, not the length of time in minutes and seconds. In minute and second form, the average length of songs in the country albums were 4:03, while the average length in the pop albums were 3:44. While 3:44 is longer than the average pop song, it is still shorter than Swift’s country tunes. This is a difference of 19 seconds, which is substantial when thinking about song length.

taylor %>% 
  group_by(album_name) %>% 
  select(album_name, duration_ms) %>% 
  summarise(length1=mean(duration_ms)) %>% 
  mutate(length2=length1/1000) %>% 
  mutate(length=length2/60)%>% 
  select(length, album_name) %>% 
  arrange(desc(-length)) -> taylor_mean_length

#sort the albums by release date
x1 <- c("Taylor Swift", "Fearless Platinum Edition", "Speak Now",
       "Red", "1989", "reputation", "Lover")
rank <- data.frame("rank" = 1:7)

taylor_mean_length %>%
  slice(match(x1, album_name)) -> tml_sorted

cbind(tml_sorted, rank) -> tml_sorted2
view(tml_sorted2)
tml_sorted2 %>%
  ggplot(aes(reorder(album_name, rank), y= length, fill= album_name)) +
  geom_col() +
  coord_flip() +
  scale_fill_manual(values = c("violetred1", "lightsteelblue1", "maroon", "violetred3", "mediumvioletred", "lightsteelblue2", "lightsteelblue3")) + theme_joy() +
  theme(legend.position="none") + ylab("Average Length of Songs") +
  theme(axis.title.y = element_blank())

taylor_mean_length %>% 
  select(album_name, length) %>% 
  kable()
album_name length
Lover 3.436464
Taylor Swift 3.566186
reputation 3.717000
1989 3.753672
Red 4.057702
Fearless Platinum Edition 4.181247
Speak Now 4.788057

Next I texted if different keys would be used for the pop albums versus the country albums. In this area, Swift has stay pretty much consistent with playing songs in C, D, E, F, and G.

taylor %>% 
  group_by(album_name, album_release_year) %>% 
  select(album_name, album_release_year, key_name) %>%
  count(key_name) ->taylor_keys


ggplot(taylor_keys, aes(key_name, fill=reorder(album_name, album_release_year), y = n))+
  geom_bar( stat = "identity")+  theme_joy()+
  scale_fill_manual(values=c("lightsteelblue1", "lightsteelblue2", "lightsteelblue3", "maroon", "violetred3", "mediumvioletred","violetred1")) +
  xlab("Key") + ylab("Count") +
  theme(legend.title = element_blank(), axis.title.x = element_text(family = ))


Then I calculated how danceable the songs were on each album. Spotify has quantified how danceable a song is with their measure of “danceability,” which the company describes as:

“How suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.”

This density graph clearly shows the pop albums above all of the country albums, with the most recent album, Lover, coming in top place. The average of the country albums’ danceability is .56, while the pop albums’ danceability is .64!

ggplot(taylor, aes(x= danceability, y= album_name, fill = ..x..)) +
  geom_joy_gradient(scale = 1)+
  scale_fill_gradient(low = "white", high = "violetred1") +
  theme_joy() +
  theme(legend.position="none") +
  xlim(0, 1) +
  xlab("Danceability") + theme(axis.title.y = element_blank())

taylor %>% 
  group_by(album_name) %>% 
  select(album_name, danceability) %>% 
  summarise(DanceAbility=mean(danceability)) %>% 
  arrange(desc(DanceAbility)) %>% 
  kable() %>% 
  kable_styling(full_width= T, position = "center") 
album_name DanceAbility
Lover 0.6582222
reputation 0.6579333
1989 0.6502308
Red 0.6228750
Fearless Platinum Edition 0.5759474
Taylor Swift 0.5452667
Speak Now 0.5449286

So I found that there is definitely a shift in length and danceability from country to pop, but not so much the key that the songs are played in. Swift’s pop songs are shorter and more danceable than her country songs. There are also several interesting findings to the change in her lyrics. Obviously the complexity of lyrics changed over time as Swift matured in the industry. Using the ‘Bing’ sentiment analysis, I found the frequency of how many positive and negative words are used per album. As you can see here, Swift’s country albums featured a larger variety of negative words. Her pop albums had a lot of variety in positive words, and also several highly-repeated positive words, as the bimodal trend shows.

taylor_country_genius <- tribble(
  ~artist, ~album,
  "Taylor Swift", "Taylor Swift",
  "Taylor Swift", "Speak Now",
  "Taylor Swift", "Fearless"
) %>%
  add_genius(artist, album)
taylor_country_genius %>% 
  unnest_tokens(word, lyric) %>% 
  anti_join(stop_words) -> taylor_country_words

taylor_pop_genius <- tribble(
  ~artist, ~album,
  "Taylor Swift", "Red",
  "Taylor Swift", "1989",
  "Taylor Swift", "reputation",
  "Taylor Swift", "Lover"
) %>%
  add_genius(artist, album)
taylor_pop_genius %>% 
  unnest_tokens(word, lyric) %>% 
  anti_join(stop_words) -> taylor_pop_words
taylor_country_words %>% 
  inner_join(get_sentiments("bing")) %>% 
  count(word, sentiment, sort = TRUE) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = n, y = as.factor(sentiment), fill = sentiment)) + 
  geom_joy(alpha = .5) + xlab("Word Count") +
  ylab("Sentiment") + theme_joy()  + theme(legend.position = "none") +
  scale_fill_manual(values = c("slategray1", "violetred1")) +
  ggtitle("Country Albums")

taylor_pop_words %>% 
  inner_join(get_sentiments("bing")) %>% 
  count(word, sentiment, sort = TRUE) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = n, y = as.factor(sentiment), fill = sentiment)) + 
  geom_joy(alpha = .5) + xlab("Word Count") +
  ylab("Sentiment") + theme_joy()  + theme(legend.position = "none") +
  scale_fill_manual(values = c("slategray1", "violetred1"))+
  ggtitle("Pop Albums")

To conclude, Swift’s music has changed sonically since her transition into country music in duration and danceability, but not very much in key. She has also changed lyrically with how often she repeats positive and negative words.