Exploring Spotify Playlists

Each country has its own identity – and one of the most defining features is music, as this project will show. Music is about culture, entertainment and inspiration, but it is also about how people connect to each other and interact with the world.

The purpose of this project is to analyse how different or how similar is the music that people around the world listen to. The focus will be placed on disentangling the musical taste of 51 countries, and identify regions, or clusters, that share a similar musical taste.

Spotify is the largest music streaming service available. The platform operates in Europe, most of the Americas, Australia, New Zealand, and parts of Asia, and it has more than 140 million users (including 60 million paying for the premium service). For this study, I will access the Spotify Web API, which provides data from the Spotify music catalog and can be accesed via standard HTTPS requests to an API endpoint.

The Spotify API provides, among other things, track information for each song, including audio statistics such as danceability, acousticness or energy. For this project, I will focus on retrieving this audio feature information from the Global Top 50 Playlist and each country Top 50 Playlist. Each feature measures an aspect of a song. Detailed information on how each feature is calculated can be found in the Spotify API Website. For example, the danceability feature in the Spotify Web API Guidance is described as:

Danceability describes 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.

Further description of the track features will be exposed later in the analysis.

Contents

  • Getting data
    • Web API Credentials
    • TOP 50 Country´s Playlists
    • Audio features
    • Audio features description
  • Data Visualisation
    • Radar Chart
      • Radar chart (Ten countries)
      • Shiny App
    • Cluster Analysis
    • Analysis by Feature
    • Shared Tracks (Global - Each Country)

Getting Data

The first step is registering our application in the API Website and getting the keys (Client ID and Client Secret) for our future requests.

The Spotify Web API has different URI (Uniform Resource Identifier) to access playlists, artists or tracks information. Consequently, the process of getting data must be divided in 2 key steps.

  • Get the Top 50 Playlist for each country.
  • Get the audio features for each country´s Playlist tracks.

Web API credentials

First, I created two variables for the Client ID and the Client Secret credentials.

spotifyKey <- "26221ddebf834ceeb8a18b2e120504fb"
spotifySecret <- "87d0056eaee34338b51539a43690812a"

After that, I requested an access token in order to authorise our app to retrieve and manage Spotify data.

library(Rspotify)
library(httr)
library(jsonlite)

spotifyEndpoint <- oauth_endpoint(NULL, 
                                  "https://accounts.spotify.com/authorize",
                                  "https://accounts.spotify.com/api/token")
spotifyToken <- spotifyOAuth("SpotifySongs", spotifyKey, spotifySecret)

Top 50 country´s Playlists

The first step to pull the country´s Playlists is to get the URI´s for each one. I stored each country´s Playlist URI (accessible from the Share option in the Spotify interface) in a .csv file and imported it in R.

library(readr)
playlistURI <- read.csv("playlistURI.csv", header = T, sep = ";")

With each Playlist URI, I applied the getPlaylistSongs from the RSpotify package and stored the Playlist information in an empty dataframe.

# Empty dataframe
PlaylistSongs <- data.frame(PlaylistID = character(),
                            Country = character(),
                            tracks = character(),
                            id = character(),
                            popularity = integer(),
                            artist = character(),
                            artistId = character(),
                            album = character(),
                            stringsAsFactors=FALSE) 
# Getting each playlist
for (i in 1:nrow(playlistURI)) {
  i <- cbind(PlaylistID = as.factor(playlistURI[i,2]),
             Country = as.factor(playlistURI[i,1]),
             getPlaylistSongs("spotifycharts",
                              playlistid = as.factor(playlistURI[i,2]),
                              token=spotifyToken))
  PlaylistSongs <- rbind(PlaylistSongs, i)
}

As we can see below, the dataframe has 8 columns and 2600 rows. The rows contain the Global playlist (50 rows) plus each country´s playlist (51 countries x 50 tracks each playlist = 2550 rows).

dim(PlaylistSongs)
## [1] 2600    8

The following table shows the first 100 rows of our dataframe PlaylistSongs. It contains the Global playlist and Argentina’s Top 50 playlist.

library(knitr)
library(kableExtra)
library(dplyr)
options(knitr.table.format = "html")
options(width = 12)

# Only Global and Argentina
kable(head(PlaylistSongs,100)) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), font_size = 12) %>%
scroll_box(width = "720px", height = "500px")
PlaylistID Country tracks id popularity artist artistId album
37i9dQZEVXbMDoHDwVN2tF Global Mi Gente 2rb5MvYT7ZIxbKW5hfcHx8 94 J Balvin 1vyhD5VmyZ7KMfW5gqLgo5 Mi Gente
37i9dQZEVXbMDoHDwVN2tF Global Despacito - Remix 5CtI0qwDJkDQGwXD1H1cLb 100 Luis Fonsi 4V8Sr092TqfHkfAA5fXXqG Despacito Feat. Justin Bieber (Remix)
37i9dQZEVXbMDoHDwVN2tF Global Wild Thoughts 1OAh8uOEOvTDqkKFsKksCi 97 DJ Khaled 0QHgL1lAIqAw0HtD7YldmP Grateful
37i9dQZEVXbMDoHDwVN2tF Global Unforgettable 3B54sVLJ402zGa6Xm4YGNe 97 French Montana 6vXTefBL93Dj5IqAWq6OTv Jungle Rules
37i9dQZEVXbMDoHDwVN2tF Global Feels 5bcTCxgc7xVfSaMV3RuVke 95 Calvin Harris 7CajNmpbOovFoOoasH2HaY Funk Wav Bounces Vol.1
37i9dQZEVXbMDoHDwVN2tF Global 2U (feat. Justin Bieber) 3A7qX2QjDlPnazUsRk5y0M 97 David Guetta 1Cs0zKBU1kc0i8ypK3B9ai 2U (feat. Justin Bieber)
37i9dQZEVXbMDoHDwVN2tF Global I’m the One 3DXncPQOG4VBw3QHh3S817 95 DJ Khaled 0QHgL1lAIqAw0HtD7YldmP Grateful
37i9dQZEVXbMDoHDwVN2tF Global Attention 4iLqG9SeJSnt0cSPICSjxv 99 Charlie Puth 6VuMaDnrHyPL1p4EHjYLi7 Attention
37i9dQZEVXbMDoHDwVN2tF Global Shape of You 7qiZfU4dY1lWllzX7mPBI3 96 Ed Sheeran 6eUKZXaKkcviH0Ku9w2n3V <U+0092><e0> (Deluxe)
37i9dQZEVXbMDoHDwVN2tF Global Strip That Down 6EpRaXYhGOB3fj4V2uDkMJ 95 Liam Payne 5pUo3fmmHT8bhCyHE52hA6 Strip That Down
37i9dQZEVXbMDoHDwVN2tF Global Thunder 0tKcYR2II1VCQWT79i5NrW 95 Imagine Dragons 53XhwfbYqKCa1cC15pYq2q Evolve
37i9dQZEVXbMDoHDwVN2tF Global New Rules 2ekn2ttSfGqwhhate0LSR0 90 Dua Lipa 6M2wZ9GZgrQXHCFfjv46we Dua Lipa (Deluxe)
37i9dQZEVXbMDoHDwVN2tF Global Mama 0NiXXAI876aGImAd6rTj8w 75 Jonas Blue 1HBjj22wzbscIZ9sEb5dyf Jonas Blue: Electronic Nature - The Mix 2017
37i9dQZEVXbMDoHDwVN2tF Global More Than You Know 3PEgB3fkiojxms35ntsTgs 48 Axwell / Ingrosso 2XnBwblw31dfGnspMIwgWz More Than You Know
37i9dQZEVXbMDoHDwVN2tF Global Sorry Not Sorry 25C5CowdsfXld2jJanbiex 92 Demi Lovato 6S2OmqARrzebs0tKUEyXyp Sorry Not Sorry
37i9dQZEVXbMDoHDwVN2tF Global XO TOUR Llif3 2eMwDehkIC1j68U6FA3Eiq 97 Lil Uzi Vert 4O15NlyKLIASxsJ0PrXPfz XO TOUR Llif3
37i9dQZEVXbMDoHDwVN2tF Global There’s Nothing Holdin’ Me Back 79cuOz3SPQTuFrp8WgftAu 95 Shawn Mendes 7n2wHs1TKAczGzO7Dd2rGr Illuminate (Deluxe)
37i9dQZEVXbMDoHDwVN2tF Global Back to You (feat. Bebe Rexha & Digital Farm Animals) 7F9vK8hNFMml4GtHsaXui6 94 Louis Tomlinson 57WHJIHrjOE3iAxpihhMnp Back to You (feat. Bebe Rexha & Digital Farm Animals)
37i9dQZEVXbMDoHDwVN2tF Global Glorious (feat. Skylar Grey) 3HVr6jTVwBHBa2flM0eURR 92 Macklemore 3JhNCzhSMTxs9WLGJJxWOY Glorious (feat. Skylar Grey)
37i9dQZEVXbMDoHDwVN2tF Global Me Reh<U+0092>_so 6De0lHrwBfPfrhorm9q1Xl 95 Danny Ocean 5H1nN1SzW0qNeUEZvuXjAj Me Reh<U+0092>_so
37i9dQZEVXbMDoHDwVN2tF Global HUMBLE. 7KXjTSCq5nL1LoYtL7XAwS 93 Kendrick Lamar 2YZyLoL8N0Wb9xBt1NhZWg DAMN.
37i9dQZEVXbMDoHDwVN2tF Global Swalla (feat. Nicki Minaj & Ty Dolla $ign) 6kex4EBAj0WHXDKZMEJaaF 97 Jason Derulo 07YZf4WDAMNwqr4jfgOZ8y Swalla (feat. Nicki Minaj & Ty Dolla $ign)
37i9dQZEVXbMDoHDwVN2tF Global Fetish (feat. Gucci Mane) 0XLOf9LhyazPX9Ld8jPiUq 91 Selena Gomez 0C8ZW7ezQVs4URX5aX7Kqx Fetish (feat. Gucci Mane)
37i9dQZEVXbMDoHDwVN2tF Global Felices los 4 0qYTZCo5Bwh1nsUFGZP3zn 96 Maluma 1r4hJ1h58CWwUQe3MxPuau Felices los 4
37i9dQZEVXbMDoHDwVN2tF Global Something Just Like This 6RUKPb4LETWmmr3iAEQktW 93 The Chainsmokers 69GGBxA162lTqCwzJG5jLp Memories…Do Not Open
37i9dQZEVXbMDoHDwVN2tF Global There for You 6jA8HL9i4QGzsj6fjoxp8Y 96 Martin Garrix 60d24wfXkVzDSfLS6hyCjZ There for You
37i9dQZEVXbMDoHDwVN2tF Global Believer 0CcQNd8CINkwQfe1RDtGV6 91 Imagine Dragons 53XhwfbYqKCa1cC15pYq2q Evolve
37i9dQZEVXbMDoHDwVN2tF Global Bank Account 5eqK0tbzUPo2SoeZsov04s 92 21 Savage 1URnnhqYAYcrqrcwql10ft Issa Album
37i9dQZEVXbMDoHDwVN2tF Global Despacito (Featuring Daddy Yankee) 4aWmUDTfIPGksMNLV2rQP2 93 Luis Fonsi 4V8Sr092TqfHkfAA5fXXqG Despacito (Featuring Daddy Yankee)
37i9dQZEVXbMDoHDwVN2tF Global Your Song 4c2W3VKsOFoIg2SFaO6DY5 94 Rita Ora 5CCwRZC6euC8Odo6y9X8jr Your Song
37i9dQZEVXbMDoHDwVN2tF Global Without You (feat. Sandro Cavazza) 6WbADFqMvR8N5u0BvtsWQE 62 Avicii 1vCWHaC5f2uS3yhpwWbIA6 AV<U+000E90C9> (01)
37i9dQZEVXbMDoHDwVN2tF Global Congratulations 3a1lNhkSLSkpJE4MSHpDu9 91 Post Malone 246dkjvS1zLTtiykXe5h60 Stoney (Deluxe)
37i9dQZEVXbMDoHDwVN2tF Global I Like Me Better 1wjzFQodRWrPcQ0AnYnvQ9 94 Lauv 5JZ7CnR6gTvEMKX4g70Amv I Like Me Better
37i9dQZEVXbMDoHDwVN2tF Global Slow Hands 167NczpNbRF7oWakJaY3Hh 91 Niall Horan 1Hsdzj7Dlq2I7tHP7501T4 Slow Hands
37i9dQZEVXbMDoHDwVN2tF Global Know No Better (feat. Quavo) 3Ytr1SUCUi6J3L9dRFx5iH 72 Major Lazer 738wLrAtLtCtFOLvQBXOXp Know No Better (feat. Quavo)
37i9dQZEVXbMDoHDwVN2tF Global Pretty Girl - Cheat Codes X CADE Remix 1NDxZ7cFAo481dtYWdrUnR 90 Maggie Lindemann 0uGk2czvcpWQA383Im6ajf Pretty Girl (Cheat Codes X CADE Remix)
37i9dQZEVXbMDoHDwVN2tF Global Symphony (feat. Zara Larsson) 1x5sYLZiu9r5E43kMlt9f8 95 Clean Bandit 6MDME20pz9RveH9rEXvrOM Symphony (feat. Zara Larsson)
37i9dQZEVXbMDoHDwVN2tF Global Esc<U+0092><U+008D>pate Conmigo 2cnKEkpVUSV4wnjQiTWfH6 94 Wisin 3E6xrwgnVfYCrCs0ePERDz Esc<U+0092><U+008D>pate Conmigo
37i9dQZEVXbMDoHDwVN2tF Global That’s What I Like 0KKkJNfGyhkQ5aFogxQAPU 95 Bruno Mars 0du5cEVh5yTK9QJze8zA0C 24K Magic
37i9dQZEVXbMDoHDwVN2tF Global Una Lady Como T<U+0092>_ 7MHN1aCFtLXjownGhvEQlF 93 Manuel Turizo 0tmwSHipWxN12fsoLcFU3B Una Lady Como T<U+0092>_
37i9dQZEVXbMDoHDwVN2tF Global Bonita 693iqPOQvhI7PobtR8CC8v 88 J Balvin 1vyhD5VmyZ7KMfW5gqLgo5 Bonita
37i9dQZEVXbMDoHDwVN2tF Global Butterfly Effect 1yxgsra98r3qAtxqiGZPiX 93 Travis Scott 0Y5tJX1MQlPlqiwlOH1tJY Butterfly Effect
37i9dQZEVXbMDoHDwVN2tF Global Bad Liar 1sCxVKWImDZSZKvG0U9B23 91 Selena Gomez 0C8ZW7ezQVs4URX5aX7Kqx Bad Liar
37i9dQZEVXbMDoHDwVN2tF Global Redbone 3kxfsdsCpFgN412fpnW85Y 90 Childish Gambino 73sIBHcqh3Z3NyqHKZ7FOL “”“Awaken, My Love!”“”
37i9dQZEVXbMDoHDwVN2tF Global No Promises (feat. Demi Lovato) 1louJpMmzEicAn7lzDalPW 92 Cheat Codes 7DMveApC7UnC2NPfPvlHSU No Promises (feat. Demi Lovato)
37i9dQZEVXbMDoHDwVN2tF Global Slide 7tr2za8SQg2CI8EDgrdtNl 87 Calvin Harris 7CajNmpbOovFoOoasH2HaY Funk Wav Bounces Vol.1
37i9dQZEVXbMDoHDwVN2tF Global Location 152lZdxL1OR0ZMW6KquMif 92 Khalid 6LuN9FCkKOj5PcnpouEgny American Teen
37i9dQZEVXbMDoHDwVN2tF Global Praying 0jdny0dhgjUwoIp5GkqEaA 32 Kesha 6LqNN22kT3074XbTVUrhzX Rainbow
37i9dQZEVXbMDoHDwVN2tF Global Stay (with Alessia Cara) 0dA2Mk56wEzDgegdC6R17g 91 Zedd 2qxJFvFYMEDqd7ui6kSAcq Stay
37i9dQZEVXbMDoHDwVN2tF Global Crying in the Club 1SJtlNRJDeYHioymcvsqev 95 Camila Cabello 4nDoRrQiYLoBzwC5BhVJzF Crying in the Club
37i9dQZEVXbMMy2roB9myp Argentina Mi Gente 2rb5MvYT7ZIxbKW5hfcHx8 94 J Balvin 1vyhD5VmyZ7KMfW5gqLgo5 Mi Gente
37i9dQZEVXbMMy2roB9myp Argentina Me Reh<U+0092>_so 6De0lHrwBfPfrhorm9q1Xl 95 Danny Ocean 5H1nN1SzW0qNeUEZvuXjAj Me Reh<U+0092>_so
37i9dQZEVXbMMy2roB9myp Argentina Bonita 693iqPOQvhI7PobtR8CC8v 88 J Balvin 1vyhD5VmyZ7KMfW5gqLgo5 Bonita
37i9dQZEVXbMMy2roB9myp Argentina Felices los 4 0qYTZCo5Bwh1nsUFGZP3zn 96 Maluma 1r4hJ1h58CWwUQe3MxPuau Felices los 4
37i9dQZEVXbMMy2roB9myp Argentina Esc<U+0092><U+008D>pate Conmigo 2cnKEkpVUSV4wnjQiTWfH6 94 Wisin 3E6xrwgnVfYCrCs0ePERDz Esc<U+0092><U+008D>pate Conmigo
37i9dQZEVXbMMy2roB9myp Argentina Ahora Dice 22eADXu8DfOAUEDw4vU8qy 89 Chris Jeday 0qTZZWLzuD59Un5r1speHm Ahora Dice
37i9dQZEVXbMMy2roB9myp Argentina Hey DJ 209gZgcfLq2aUuu51vOWBl 92 CNCO 0eecdvMrqBftK0M1VKhaF4 Hey DJ
37i9dQZEVXbMMy2roB9myp Argentina Olha a Explos<U+0092><U+00A3>o 6m2LNopVJKsvBB9l7Z1rwn 83 MC Kevinho 1mXAhKnZEdF6rotyyd4GBi Olha a Explos<U+0092><U+00A3>o
37i9dQZEVXbMMy2roB9myp Argentina Tu Foto 0Szp49tpFasIjX04Mcsydp 90 Ozuna 1i8SpTcr7yvPOmcqrbnVXY Tu Foto
37i9dQZEVXbMMy2roB9myp Argentina El Farsante 66gNNRsKkmECPQUrvpMQtS 3 DJ Jonathan 5RSYz1KaYXbHfKdlaxAI8O Nivel Urbano
37i9dQZEVXbMMy2roB9myp Argentina Shape of You 7qiZfU4dY1lWllzX7mPBI3 96 Ed Sheeran 6eUKZXaKkcviH0Ku9w2n3V <U+0092><e0> (Deluxe)
37i9dQZEVXbMMy2roB9myp Argentina Una Lady Como T<U+0092>_ 7MHN1aCFtLXjownGhvEQlF 93 Manuel Turizo 0tmwSHipWxN12fsoLcFU3B Una Lady Como T<U+0092>_
37i9dQZEVXbMMy2roB9myp Argentina Krippy Kush 3rgjBiAMVGnxmsTDmUy8vb 76 Farruko 329e4yvIujISKGKz1BZZbO Krippy Kush
37i9dQZEVXbMMy2roB9myp Argentina B<U+0092><U+008D>ilame 7lRsNbdOGykkMAgsqs4R1C 86 Nacho 2ayNSoKPCRAfjp6hQ76hRu Bailame
37i9dQZEVXbMMy2roB9myp Argentina La Rompe Corazones 4okba5wu9mMLXx79DXLKi3 86 Daddy Yankee 4VMYDCV2IEDYJArk749S6m La Rompe Corazones
37i9dQZEVXbMMy2roB9myp Argentina Mayores 7JNh1cfm0eXjqFVOzKLyau 85 Becky G 4obzFoKoKRHIphyHzJ35G3 Mayores
37i9dQZEVXbMMy2roB9myp Argentina Si T<U+0092>_ La Ves 4yN6xPLopmTLvc27pO9LIE 87 Nicky Jam 1SupJlEpv7RS2tPNRaHViT F<U+0092><U+00A9>nix
37i9dQZEVXbMMy2roB9myp Argentina Sola (Remix) [feat. Daddy Yankee, Wisin, Farruko, Zion & Lennox] 5q2JbCNi4FcnglgPfxcV65 88 Anuel Aa 2R21vXR83lH98kGeO99Y66 Sola (Remix) [feat. Daddy Yankee, Wisin, Farruko, Zion & Lennox]
37i9dQZEVXbMMy2roB9myp Argentina Bes<U+0092><U+008D>ndote 13X0XdLMOdtbXVtAj2ox4h 87 Piso 21 4bw2Am3p9ji3mYsXNXtQcd Bes<U+0092><U+008D>ndote
37i9dQZEVXbMMy2roB9myp Argentina Sigo Extra<U+0092><U+00B1><U+0092><U+008D>ndote 6qDF4wWL49CAVbgT7yuHl8 85 J Balvin 1vyhD5VmyZ7KMfW5gqLgo5 Energ<U+0092>_a
37i9dQZEVXbMMy2roB9myp Argentina Despacito (Featuring Daddy Yankee) 4aWmUDTfIPGksMNLV2rQP2 93 Luis Fonsi 4V8Sr092TqfHkfAA5fXXqG Despacito (Featuring Daddy Yankee)
37i9dQZEVXbMMy2roB9myp Argentina Ahora Me Llama 61HHDBLqF3AmSvLfHKNGd2 81 Karol G 790FomKkXshlbRYZFtlgla Ahora Me Llama
37i9dQZEVXbMMy2roB9myp Argentina Me Llamas (feat. Maluma) - Remix 5hEM0JchdVzQ5PwvSfITeX 88 Piso 21 4bw2Am3p9ji3mYsXNXtQcd Me Llamas (feat. Maluma) [Remix]
37i9dQZEVXbMMy2roB9myp Argentina Otra Vez (feat. J Balvin) 3QwBODjSEzelZyVjxPOHdq 86 Zion & Lennox 21451j1KhjAiaYKflxBjr1 Motivan2
37i9dQZEVXbMMy2roB9myp Argentina Bella y Sensual 0ERbK7qVqveCaBWIiYCrl3 83 Romeo Santos 5lwmRuXgjX8xIwlnauTZIP Golden
37i9dQZEVXbMMy2roB9myp Argentina Me Enamor<U+0092><U+00A9> 4qknM1pQz53QOyfDVTjcM9 90 Shakira 0EmeFodog0BfCgMzAIvKQp El Dorado
37i9dQZEVXbMMy2roB9myp Argentina El Amante 3umS4y3uQDkqekNjVpiRUs 89 Nicky Jam 1SupJlEpv7RS2tPNRaHViT F<U+0092><U+00A9>nix
37i9dQZEVXbMMy2roB9myp Argentina Despacito - Remix 5CtI0qwDJkDQGwXD1H1cLb 100 Luis Fonsi 4V8Sr092TqfHkfAA5fXXqG Despacito Feat. Justin Bieber (Remix)
37i9dQZEVXbMMy2roB9myp Argentina Bebe (feat. Anuel AA) 6SIrNxmmdbv1KUbFBu1PaN 83 Ozuna 1i8SpTcr7yvPOmcqrbnVXY Bebe (feat. Anuel AA)
37i9dQZEVXbMMy2roB9myp Argentina SUBEME LA RADIO 7nKBxz47S9SD79N086fuhn 94 Enrique Iglesias 7qG3b048QCHVRO5Pv1T5lw SUBEME LA RADIO
37i9dQZEVXbMMy2roB9myp Argentina Una y Otra Vez 3VSt7R9LHTomKGP1RhkvuT 74 Rombai 5KQX0Ui06LVm6PApyicRFK Una y Otra Vez
37i9dQZEVXbMMy2roB9myp Argentina Hey Ma (with Pitbull & J Balvin feat. Camila Cabello) - Spanish Version 2Vdub5mY4lad7w64bFPUez 75 Pitbull 0TnOYISbd1XYRBk9myaseg Hey Ma (with Pitbull & J Balvin feat. Camila Cabello) [Spanish Version]
37i9dQZEVXbMMy2roB9myp Argentina 2U (feat. Justin Bieber) 3A7qX2QjDlPnazUsRk5y0M 97 David Guetta 1Cs0zKBU1kc0i8ypK3B9ai 2U (feat. Justin Bieber)
37i9dQZEVXbMMy2roB9myp Argentina Reggaet<U+0092>_n Lento (Bailemos) 3AEZUABDXNtecAOSC1qTfo 87 CNCO 0eecdvMrqBftK0M1VKhaF4 Primera Cita
37i9dQZEVXbMMy2roB9myp Argentina Soy Peor Remix (feat. J Balvin, Ozuna & Arcangel) 4UG962ViiLqoUyx0RjCcwP 82 Bad Bunny 4q3ewBCX7sLwd24euuV69X Soy Peor Remix
37i9dQZEVXbMMy2roB9myp Argentina Swalla (feat. Nicki Minaj & Ty Dolla $ign) 6kex4EBAj0WHXDKZMEJaaF 97 Jason Derulo 07YZf4WDAMNwqr4jfgOZ8y Swalla (feat. Nicki Minaj & Ty Dolla $ign)
37i9dQZEVXbMMy2roB9myp Argentina Piel a Piel 2q3B7GLCEA4uYvuo2g5P82 73 Dame 5 0J65S0gB0D1gDEd0hK196k Piel a Piel
37i9dQZEVXbMMy2roB9myp Argentina La Tonta 0imzSFFJDCdKruduJHFN6A 68 Jimena Baron 2VcOA5QxHanUnsQxVw2OP5 La Tonta
37i9dQZEVXbMMy2roB9myp Argentina Traicionera 5J1c3M4EldCfNxXwrwt8mT 81 Sebastian Yatra 07YUOmWljBTXwIseAUd9TW Traicionera
37i9dQZEVXbMMy2roB9myp Argentina Alguien Robo 5i50gKdLAjjIr7UxRT5IVy 83 Sebastian Yatra 07YUOmWljBTXwIseAUd9TW Alguien Rob<U+0092>_
37i9dQZEVXbMMy2roB9myp Argentina Te Quiero Pa<U+0382>Mi 3BY2mafsbsoKGqS380Xnuz 80 Don Omar 33ScadVnbm2X8kkUqOkC6Z King Of Kings 10th Anniversary (Remastered)
37i9dQZEVXbMMy2roB9myp Argentina Cuando Se Pone a Bailar 1MpKZi1zTXpERKwxmOu1PH 75 Rombai 5KQX0Ui06LVm6PApyicRFK Cuando Se Pone a Bailar
37i9dQZEVXbMMy2roB9myp Argentina Attention 4iLqG9SeJSnt0cSPICSjxv 99 Charlie Puth 6VuMaDnrHyPL1p4EHjYLi7 Attention
37i9dQZEVXbMMy2roB9myp Argentina Vacaciones 3dQDid3IUNhZy1OehIfYfE 85 Wisin 3E6xrwgnVfYCrCs0ePERDz Vacaciones
37i9dQZEVXbMMy2roB9myp Argentina Loco Enamorado 4N1c5rmWOzRmB9SMacr5wB 83 Abraham Mateo 2bxxlINUlcMQQb39K7IopR Loco Enamorado
37i9dQZEVXbMMy2roB9myp Argentina Chantaje 6mICuAdrwEjh6Y6lroV2Kg 88 Shakira 0EmeFodog0BfCgMzAIvKQp El Dorado
37i9dQZEVXbMMy2roB9myp Argentina Gyal You A Party Animal - Remix 1AkTW13ysu0AJrwuM6UY0I 80 Charly Black 5sK8BsvyDl4TFA6KaBf8or Gyal You A Party Animal (Remix)
37i9dQZEVXbMMy2roB9myp Argentina Imitadora 6r46lnXFbE9fr2d3KNaGbe 82 Romeo Santos 5lwmRuXgjX8xIwlnauTZIP Golden
37i9dQZEVXbMMy2roB9myp Argentina Robarte un Beso 4z3GJkrtH97Bj6fRta983T 80 Carlos Vives 4vhNDa5ycK0ST968ek7kRr Robarte un Beso
37i9dQZEVXbMMy2roB9myp Argentina Ay Mi Dios 6stYbAJgTszHAHZMPxWWCY 68 IAmChino 0b2GL7Y02vu50qieoQmw1w Ay Mi Dios

Audio features

First, I wrote a formula (getFeatures) that extracts the audio features for any specific ID stored as a vector.

getFeatures <- function (vector_id, token) 
{
  link <- httr::GET(paste0("https://api.spotify.com/v1/audio-features/?ids=", 
  vector_id), httr::config(token = token))
  list <- httr::content(link)
  return(list)
}

Next, I included getFeatures in another formula (get_features). The latter formula extracts the audio features for the track ID’s vector and returns them in a dataframe.

get_features <- function (x) {
getFeatures2 <- getFeatures(vector_id = x, token = spotifyToken)
features_output <- do.call(rbind, lapply(getFeatures2$audio_features, data.frame, stringsAsFactors=FALSE))
}

Using the formula created above, we will be able to extract the audio features for each track. In order to do so, I need a vector containing each track ID. The rate limit for the Spotify API is 100 tracks, so I decided to create a vector with track IDs for each country.

Global_vc <- paste(as.character(PlaylistSongs$id[1:50]), sep="", collapse=",")
Argentina_vc <- paste(as.character(PlaylistSongs$id[51:100]), sep="", collapse=",")
Australia_vc <- paste(as.character(PlaylistSongs$id[101:150]), sep="", collapse=",")
Austria_vc <- paste(as.character(PlaylistSongs$id[151:200]), sep="", collapse=",")
Belgium_vc <- paste(as.character(PlaylistSongs$id[201:250]), sep="", collapse=",")
Bolivia_vc <- paste(as.character(PlaylistSongs$id[251:300]), sep="", collapse=",")
Brazil_vc <- paste(as.character(PlaylistSongs$id[301:350]), sep="", collapse=",")
Canada_vc <- paste(as.character(PlaylistSongs$id[351:400]), sep="", collapse=",")
Chile_vc <- paste(as.character(PlaylistSongs$id[401:450]), sep="", collapse=",")
Colombia_vc <- paste(as.character(PlaylistSongs$id[451:500]), sep="", collapse=",")
CostaRica_vc <- paste(as.character(PlaylistSongs$id[501:550]), sep="", collapse=",")
CzechRepublic_vc <- paste(as.character(PlaylistSongs$id[551:600]), sep="",collapse=",")
Denmark_vc <- paste(as.character(PlaylistSongs$id[601:650]), sep="", collapse=",")
DominicanRep_vc <- paste(as.character(PlaylistSongs$id[651:700]), sep="", collapse=",")
Ecuador_vc <- paste(as.character(PlaylistSongs$id[701:750]), sep="", collapse=",")
ElSalvador_vc <- paste(as.character(PlaylistSongs$id[751:800]), sep="", collapse=",")
Finland_vc <- paste(as.character(PlaylistSongs$id[801:850]), sep="", collapse=",")
France_vc <- paste(as.character(PlaylistSongs$id[851:900]), sep="", collapse=",")
Germany_vc <- paste(as.character(PlaylistSongs$id[901:950]), sep="", collapse=",")
Greece_vc <- paste(as.character(PlaylistSongs$id[951:1000]), sep="", collapse=",")
Guatemala_vc <- paste(as.character(PlaylistSongs$id[1001:1050]), sep="", collapse=",")
Honduras_vc <- paste(as.character(PlaylistSongs$id[1051:1100]), sep="", collapse=",")
HongKong_vc <- paste(as.character(PlaylistSongs$id[1101:1150]), sep="", collapse=",")
Hungary_vc <- paste(as.character(PlaylistSongs$id[1151:1200]), sep="", collapse=",")
Iceland_vc <- paste(as.character(PlaylistSongs$id[1201:1250]), sep="", collapse=",")
Indonesia_vc <- paste(as.character(PlaylistSongs$id[1251:1300]), sep="", collapse=",")
Ireland_vc <- paste(as.character(PlaylistSongs$id[1301:1350]), sep="", collapse=",")
Italy_vc <- paste(as.character(PlaylistSongs$id[1351:1400]), sep="", collapse=",")
Japan_vc <- paste(as.character(PlaylistSongs$id[1401:1450]), sep="", collapse=",")
Latvia_vc <- paste(as.character(PlaylistSongs$id[1451:1500]), sep="", collapse=",")
Lithuania_vc <- paste(as.character(PlaylistSongs$id[1501:1550]), sep="", collapse=",")
Malaysia_vc <- paste(as.character(PlaylistSongs$id[1551:1600]), sep="", collapse=",")
Mexico_vc <- paste(as.character(PlaylistSongs$id[1601:1650]), sep="", collapse=",")
Netherlands_vc <- paste(as.character(PlaylistSongs$id[1651:1700]), sep="",collapse=",")
NewZealand_vc <- paste(as.character(PlaylistSongs$id[1701:1750]), sep="", collapse=",")
Norway_vc <- paste(as.character(PlaylistSongs$id[1751:1800]), sep="", collapse=",")
Panama_vc <- paste(as.character(PlaylistSongs$id[1801:1850]), sep="", collapse=",")
Paraguay_vc <- paste(as.character(PlaylistSongs$id[1851:1900]), sep="", collapse=",")
Peru_vc <- paste(as.character(PlaylistSongs$id[1901:1950]), sep="", collapse=",")
Phillipp_vc <- paste(as.character(PlaylistSongs$id[1951:2000]), sep="", collapse=",")
Poland_vc <- paste(as.character(PlaylistSongs$id[2001:2050]), sep="", collapse=",")
Portugal_vc <- paste(as.character(PlaylistSongs$id[2051:2100]), sep="", collapse=",")
Singapore_vc <- paste(as.character(PlaylistSongs$id[2101:2150]), sep="", collapse=",")
Slovakia_vc <- paste(as.character(PlaylistSongs$id[2151:2200]), sep="", collapse=",")
Spain_vc <- paste(as.character(PlaylistSongs$id[2201:2250]), sep="", collapse=",")
Sweden_vc <- paste(as.character(PlaylistSongs$id[2251:2300]), sep="", collapse=",")
Switzerland_vc <- paste(as.character(PlaylistSongs$id[2301:2350]), sep="",collapse=",")
Taiwan_vc <- paste(as.character(PlaylistSongs$id[2351:2400]), sep="", collapse=",")
Turkey_vc <- paste(as.character(PlaylistSongs$id[2401:2450]), sep="", collapse=",")
UK_vc <- paste(as.character(PlaylistSongs$id[2451:2500]), sep="", collapse=",")
US_vc <- paste(as.character(PlaylistSongs$id[2501:2550]), sep="", collapse=",")
Uruguay_vc <- paste(as.character(PlaylistSongs$id[2551:2600]), sep="", collapse=",")

Next, we apply the get_features formula to each vector obtaining the audio features for each country.

Global <- get_features(Global_vc)
## Auto-refreshing stale OAuth token.
Argentina <- get_features(Argentina_vc)
Australia <- get_features(Australia_vc)
Austria <- get_features(Austria_vc)
Belgium <- get_features(Belgium_vc)
Bolivia <- get_features(Bolivia_vc)
Brazil <- get_features(Brazil_vc)
Canada <- get_features(Canada_vc)
Chile <- get_features(Chile_vc)
Colombia <- get_features(Colombia_vc)
CostaRica <- get_features(CostaRica_vc)
CzechRepublic <- get_features(CzechRepublic_vc)
Denmark <- get_features(Denmark_vc)
DominicanRepublic <- get_features(DominicanRep_vc)
Ecuador <- get_features(Ecuador_vc)
ElSalvador <- get_features(ElSalvador_vc)
Finland <- get_features(Finland_vc)
France <- get_features(France_vc)
Germany <- get_features(Germany_vc)
Greece <- get_features(Greece_vc)
Guatemala <- get_features(Guatemala_vc)
Honduras <- get_features(Honduras_vc)
HongKong <- get_features(HongKong_vc)
Hungary <- get_features(Hungary_vc)
Iceland <- get_features(Iceland_vc)
Indonesia <- get_features(Indonesia_vc)
Ireland <- get_features(Ireland_vc)
Italy <- get_features(Italy_vc)
Japan <- get_features(Japan_vc)
Latvia <- get_features(Latvia_vc)
Lithuania <- get_features(Lithuania_vc)
Malaysia <- get_features(Malaysia_vc)
Mexico <- get_features(Mexico_vc)
Netherlands <- get_features(Netherlands_vc)
NewZealand <- get_features(NewZealand_vc)
Norway <- get_features(Norway_vc)
Panama <- get_features(Panama_vc)
Paraguay <- get_features(Paraguay_vc)
Peru <- get_features(Peru_vc)
Phillippines <- get_features(Phillipp_vc)
Poland <- get_features(Poland_vc)
Portugal <- get_features(Portugal_vc)
Singapore <- get_features(Singapore_vc)
Slovakia <- get_features(Slovakia_vc)
Spain <- get_features(Spain_vc)
Sweden <- get_features(Sweden_vc)
Switzerland <- get_features(Switzerland_vc)
Taiwan <- get_features(Taiwan_vc)
Turkey <- get_features(Turkey_vc)
UnitedKingdom <- get_features(UK_vc)
UnitedStates <- get_features(US_vc)
Uruguay <- get_features(Uruguay_vc)

After that, I merged each country´s audio features dataframe into a new one, Features_df. It contains the audio features for all the tracks in every Top 50 Playlist.

library(gdata) 
Features_df <- combine(Global,Argentina,Australia,Austria,Belgium,Bolivia,Brazil,Canada,Chile,Colombia,CostaRica,CzechRepublic,Denmark,DominicanRepublic,Ecuador,ElSalvador,Finland,France,Germany,Greece,Guatemala,Honduras,HongKong,Hungary,Iceland,Indonesia,Ireland,Italy,Japan,Latvia,Lithuania,Malaysia,Mexico,Netherlands,NewZealand,Norway,Panama,Paraguay,Peru,Phillippines,Poland,Portugal,Singapore,Slovakia,Spain,Sweden,Switzerland,Taiwan,Turkey,UnitedKingdom,UnitedStates,Uruguay)

A preview of the Features_df dataframe can be found below. It only shows 100 rows with the data for Global and Argentina. The last column (Source) contains the country.

options(knitr.table.format = "html")
options(width = 12)

kable(head(Features_df, 100)) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), font_size = 12) %>%
scroll_box(width = "720px", height = "500px")
danceability energy key loudness mode speechiness acousticness instrumentalness liveness valence tempo type id uri track_href analysis_url duration_ms time_signature source
0.543 0.677 11 -4.915 0 0.0993 0.014800 6.20e-06 0.1300 0.279 103.809 audio_features 2rb5MvYT7ZIxbKW5hfcHx8 spotify:track:2rb5MvYT7ZIxbKW5hfcHx8 https://api.spotify.com/v1/tracks/2rb5MvYT7ZIxbKW5hfcHx8 https://api.spotify.com/v1/audio-analysis/2rb5MvYT7ZIxbKW5hfcHx8 189440 4 Global
0.694 0.815 2 -4.328 1 0.1200 0.229000 0.00e+00 0.0924 0.826 88.931 audio_features 5CtI0qwDJkDQGwXD1H1cLb spotify:track:5CtI0qwDJkDQGwXD1H1cLb https://api.spotify.com/v1/tracks/5CtI0qwDJkDQGwXD1H1cLb https://api.spotify.com/v1/audio-analysis/5CtI0qwDJkDQGwXD1H1cLb 228827 4 Global
0.671 0.672 0 -3.094 0 0.0688 0.032900 0.00e+00 0.1180 0.636 97.980 audio_features 1OAh8uOEOvTDqkKFsKksCi spotify:track:1OAh8uOEOvTDqkKFsKksCi https://api.spotify.com/v1/tracks/1OAh8uOEOvTDqkKFsKksCi https://api.spotify.com/v1/audio-analysis/1OAh8uOEOvTDqkKFsKksCi 204173 4 Global
0.726 0.769 6 -5.043 1 0.1230 0.029300 1.01e-02 0.1040 0.750 97.985 audio_features 3B54sVLJ402zGa6Xm4YGNe spotify:track:3B54sVLJ402zGa6Xm4YGNe https://api.spotify.com/v1/tracks/3B54sVLJ402zGa6Xm4YGNe https://api.spotify.com/v1/audio-analysis/3B54sVLJ402zGa6Xm4YGNe 233902 4 Global
0.893 0.745 11 -3.105 0 0.0571 0.064200 0.00e+00 0.0943 0.874 101.018 audio_features 5bcTCxgc7xVfSaMV3RuVke spotify:track:5bcTCxgc7xVfSaMV3RuVke https://api.spotify.com/v1/tracks/5bcTCxgc7xVfSaMV3RuVke https://api.spotify.com/v1/audio-analysis/5bcTCxgc7xVfSaMV3RuVke 223413 4 Global
0.548 0.650 8 -5.827 0 0.0591 0.219000 0.00e+00 0.2250 0.557 144.937 audio_features 3A7qX2QjDlPnazUsRk5y0M spotify:track:3A7qX2QjDlPnazUsRk5y0M https://api.spotify.com/v1/tracks/3A7qX2QjDlPnazUsRk5y0M https://api.spotify.com/v1/audio-analysis/3A7qX2QjDlPnazUsRk5y0M 194897 4 Global
0.609 0.668 7 -4.284 1 0.0367 0.055200 0.00e+00 0.1670 0.800 80.924 audio_features 3DXncPQOG4VBw3QHh3S817 spotify:track:3DXncPQOG4VBw3QHh3S817 https://api.spotify.com/v1/tracks/3DXncPQOG4VBw3QHh3S817 https://api.spotify.com/v1/audio-analysis/3DXncPQOG4VBw3QHh3S817 288600 4 Global
0.774 0.626 3 -4.432 0 0.0432 0.096900 3.12e-05 0.0848 0.758 100.041 audio_features 4iLqG9SeJSnt0cSPICSjxv spotify:track:4iLqG9SeJSnt0cSPICSjxv https://api.spotify.com/v1/tracks/4iLqG9SeJSnt0cSPICSjxv https://api.spotify.com/v1/audio-analysis/4iLqG9SeJSnt0cSPICSjxv 211475 4 Global
0.825 0.652 1 -3.183 0 0.0802 0.581000 0.00e+00 0.0931 0.931 95.977 audio_features 7qiZfU4dY1lWllzX7mPBI3 spotify:track:7qiZfU4dY1lWllzX7mPBI3 https://api.spotify.com/v1/tracks/7qiZfU4dY1lWllzX7mPBI3 https://api.spotify.com/v1/audio-analysis/7qiZfU4dY1lWllzX7mPBI3 233713 4 Global
0.869 0.485 6 -5.595 1 0.0545 0.246000 0.00e+00 0.0765 0.542 106.028 audio_features 6EpRaXYhGOB3fj4V2uDkMJ spotify:track:6EpRaXYhGOB3fj4V2uDkMJ https://api.spotify.com/v1/tracks/6EpRaXYhGOB3fj4V2uDkMJ https://api.spotify.com/v1/audio-analysis/6EpRaXYhGOB3fj4V2uDkMJ 204502 4 Global
0.600 0.810 0 -4.749 1 0.0479 0.006830 2.10e-01 0.1550 0.252 167.880 audio_features 0tKcYR2II1VCQWT79i5NrW spotify:track:0tKcYR2II1VCQWT79i5NrW https://api.spotify.com/v1/tracks/0tKcYR2II1VCQWT79i5NrW https://api.spotify.com/v1/audio-analysis/0tKcYR2II1VCQWT79i5NrW 187147 4 Global
0.756 0.682 9 -6.577 0 0.0753 0.002740 8.80e-06 0.1470 0.589 116.008 audio_features 2ekn2ttSfGqwhhate0LSR0 spotify:track:2ekn2ttSfGqwhhate0LSR0 https://api.spotify.com/v1/tracks/2ekn2ttSfGqwhhate0LSR0 https://api.spotify.com/v1/audio-analysis/2ekn2ttSfGqwhhate0LSR0 209333 4 Global
0.746 0.793 11 -4.209 0 0.0412 0.110000 0.00e+00 0.0528 0.552 104.027 audio_features 0NiXXAI876aGImAd6rTj8w spotify:track:0NiXXAI876aGImAd6rTj8w https://api.spotify.com/v1/tracks/0NiXXAI876aGImAd6rTj8w https://api.spotify.com/v1/audio-analysis/0NiXXAI876aGImAd6rTj8w 181615 4 Global
0.644 0.743 5 -5.002 0 0.0355 0.034000 0.00e+00 0.2570 0.532 123.074 audio_features 3PEgB3fkiojxms35ntsTgs spotify:track:3PEgB3fkiojxms35ntsTgs https://api.spotify.com/v1/tracks/3PEgB3fkiojxms35ntsTgs https://api.spotify.com/v1/audio-analysis/3PEgB3fkiojxms35ntsTgs 203000 4 Global
0.701 0.638 11 -6.889 0 0.2380 0.025200 0.00e+00 0.2560 0.867 144.084 audio_features 25C5CowdsfXld2jJanbiex spotify:track:25C5CowdsfXld2jJanbiex https://api.spotify.com/v1/tracks/25C5CowdsfXld2jJanbiex https://api.spotify.com/v1/audio-analysis/25C5CowdsfXld2jJanbiex 203760 4 Global
0.732 0.750 11 -6.366 0 0.2310 0.002640 0.00e+00 0.1090 0.392 155.096 audio_features 2eMwDehkIC1j68U6FA3Eiq spotify:track:2eMwDehkIC1j68U6FA3Eiq https://api.spotify.com/v1/tracks/2eMwDehkIC1j68U6FA3Eiq https://api.spotify.com/v1/audio-analysis/2eMwDehkIC1j68U6FA3Eiq 182707 4 Global
0.857 0.800 2 -4.035 1 0.0583 0.381000 0.00e+00 0.0913 0.965 121.996 audio_features 79cuOz3SPQTuFrp8WgftAu spotify:track:79cuOz3SPQTuFrp8WgftAu https://api.spotify.com/v1/tracks/79cuOz3SPQTuFrp8WgftAu https://api.spotify.com/v1/audio-analysis/79cuOz3SPQTuFrp8WgftAu 199440 4 Global
0.683 0.530 5 -4.918 0 0.1420 0.207000 0.00e+00 0.3940 0.632 75.016 audio_features 7F9vK8hNFMml4GtHsaXui6 spotify:track:7F9vK8hNFMml4GtHsaXui6 https://api.spotify.com/v1/tracks/7F9vK8hNFMml4GtHsaXui6 https://api.spotify.com/v1/audio-analysis/7F9vK8hNFMml4GtHsaXui6 190428 4 Global
0.731 0.794 0 -5.126 0 0.0522 0.032300 2.59e-05 0.1120 0.350 139.994 audio_features 3HVr6jTVwBHBa2flM0eURR spotify:track:3HVr6jTVwBHBa2flM0eURR https://api.spotify.com/v1/tracks/3HVr6jTVwBHBa2flM0eURR https://api.spotify.com/v1/audio-analysis/3HVr6jTVwBHBa2flM0eURR 220454 4 Global
0.744 0.804 1 -6.327 1 0.0677 0.023100 0.00e+00 0.0494 0.456 104.823 audio_features 6De0lHrwBfPfrhorm9q1Xl spotify:track:6De0lHrwBfPfrhorm9q1Xl https://api.spotify.com/v1/tracks/6De0lHrwBfPfrhorm9q1Xl https://api.spotify.com/v1/audio-analysis/6De0lHrwBfPfrhorm9q1Xl 205715 4 Global
0.904 0.611 1 -6.842 0 0.0888 0.000259 2.03e-05 0.0976 0.427 150.020 audio_features 7KXjTSCq5nL1LoYtL7XAwS spotify:track:7KXjTSCq5nL1LoYtL7XAwS https://api.spotify.com/v1/tracks/7KXjTSCq5nL1LoYtL7XAwS https://api.spotify.com/v1/audio-analysis/7KXjTSCq5nL1LoYtL7XAwS 177000 4 Global
0.696 0.817 1 -3.862 1 0.1090 0.075000 0.00e+00 0.1870 0.779 98.064 audio_features 6kex4EBAj0WHXDKZMEJaaF spotify:track:6kex4EBAj0WHXDKZMEJaaF https://api.spotify.com/v1/tracks/6kex4EBAj0WHXDKZMEJaaF https://api.spotify.com/v1/audio-analysis/6kex4EBAj0WHXDKZMEJaaF 216409 4 Global
0.708 0.610 2 -4.522 1 0.0574 0.020400 4.40e-06 0.0641 0.296 123.038 audio_features 0XLOf9LhyazPX9Ld8jPiUq spotify:track:0XLOf9LhyazPX9Ld8jPiUq https://api.spotify.com/v1/tracks/0XLOf9LhyazPX9Ld8jPiUq https://api.spotify.com/v1/audio-analysis/0XLOf9LhyazPX9Ld8jPiUq 186113 4 Global
0.755 0.789 5 -4.502 1 0.1460 0.231000 0.00e+00 0.3510 0.734 93.973 audio_features 0qYTZCo5Bwh1nsUFGZP3zn spotify:track:0qYTZCo5Bwh1nsUFGZP3zn https://api.spotify.com/v1/tracks/0qYTZCo5Bwh1nsUFGZP3zn https://api.spotify.com/v1/audio-analysis/0qYTZCo5Bwh1nsUFGZP3zn 229849 4 Global
0.617 0.635 11 -6.769 0 0.0317 0.049800 1.44e-05 0.1640 0.436 103.019 audio_features 6RUKPb4LETWmmr3iAEQktW spotify:track:6RUKPb4LETWmmr3iAEQktW https://api.spotify.com/v1/tracks/6RUKPb4LETWmmr3iAEQktW https://api.spotify.com/v1/audio-analysis/6RUKPb4LETWmmr3iAEQktW 247160 4 Global
0.611 0.644 6 -7.607 0 0.0553 0.124000 0.00e+00 0.1240 0.137 105.969 audio_features 6jA8HL9i4QGzsj6fjoxp8Y spotify:track:6jA8HL9i4QGzsj6fjoxp8Y https://api.spotify.com/v1/tracks/6jA8HL9i4QGzsj6fjoxp8Y https://api.spotify.com/v1/audio-analysis/6jA8HL9i4QGzsj6fjoxp8Y 221904 4 Global
0.779 0.787 10 -4.305 0 0.1080 0.052400 0.00e+00 0.1400 0.700 124.982 audio_features 0CcQNd8CINkwQfe1RDtGV6 spotify:track:0CcQNd8CINkwQfe1RDtGV6 https://api.spotify.com/v1/tracks/0CcQNd8CINkwQfe1RDtGV6 https://api.spotify.com/v1/audio-analysis/0CcQNd8CINkwQfe1RDtGV6 204347 4 Global
0.884 0.346 8 -8.228 0 0.3510 0.015100 7.00e-06 0.0871 0.378 75.016 audio_features 5eqK0tbzUPo2SoeZsov04s spotify:track:5eqK0tbzUPo2SoeZsov04s https://api.spotify.com/v1/tracks/5eqK0tbzUPo2SoeZsov04s https://api.spotify.com/v1/audio-analysis/5eqK0tbzUPo2SoeZsov04s 220307 4 Global
0.660 0.786 2 -4.757 1 0.1700 0.209000 0.00e+00 0.1120 0.849 177.833 audio_features 4aWmUDTfIPGksMNLV2rQP2 spotify:track:4aWmUDTfIPGksMNLV2rQP2 https://api.spotify.com/v1/tracks/4aWmUDTfIPGksMNLV2rQP2 https://api.spotify.com/v1/audio-analysis/4aWmUDTfIPGksMNLV2rQP2 228200 4 Global
0.855 0.624 1 -4.093 1 0.0488 0.158000 0.00e+00 0.0513 0.962 117.959 audio_features 4c2W3VKsOFoIg2SFaO6DY5 spotify:track:4c2W3VKsOFoIg2SFaO6DY5 https://api.spotify.com/v1/tracks/4c2W3VKsOFoIg2SFaO6DY5 https://api.spotify.com/v1/audio-analysis/4c2W3VKsOFoIg2SFaO6DY5 180757 4 Global
0.652 0.855 2 -4.832 1 0.0441 0.001790 0.00e+00 0.0404 0.287 134.009 audio_features 6WbADFqMvR8N5u0BvtsWQE spotify:track:6WbADFqMvR8N5u0BvtsWQE https://api.spotify.com/v1/tracks/6WbADFqMvR8N5u0BvtsWQE https://api.spotify.com/v1/audio-analysis/6WbADFqMvR8N5u0BvtsWQE 181673 4 Global
0.627 0.812 6 -4.215 1 0.0358 0.198000 0.00e+00 0.2120 0.497 123.071 audio_features 3a1lNhkSLSkpJE4MSHpDu9 spotify:track:3a1lNhkSLSkpJE4MSHpDu9 https://api.spotify.com/v1/tracks/3a1lNhkSLSkpJE4MSHpDu9 https://api.spotify.com/v1/audio-analysis/3a1lNhkSLSkpJE4MSHpDu9 220293 4 Global
0.752 0.505 9 -7.621 1 0.2530 0.535000 2.60e-06 0.1040 0.407 91.970 audio_features 1wjzFQodRWrPcQ0AnYnvQ9 spotify:track:1wjzFQodRWrPcQ0AnYnvQ9 https://api.spotify.com/v1/tracks/1wjzFQodRWrPcQ0AnYnvQ9 https://api.spotify.com/v1/audio-analysis/1wjzFQodRWrPcQ0AnYnvQ9 197437 4 Global
0.728 0.426 0 -6.690 1 0.0509 0.014200 0.00e+00 0.0546 0.850 85.908 audio_features 167NczpNbRF7oWakJaY3Hh spotify:track:167NczpNbRF7oWakJaY3Hh https://api.spotify.com/v1/tracks/167NczpNbRF7oWakJaY3Hh https://api.spotify.com/v1/audio-analysis/167NczpNbRF7oWakJaY3Hh 188174 4 Global
0.738 0.814 7 -4.414 0 0.0999 0.132000 9.60e-06 0.1260 0.498 119.041 audio_features 3Ytr1SUCUi6J3L9dRFx5iH spotify:track:3Ytr1SUCUi6J3L9dRFx5iH https://api.spotify.com/v1/tracks/3Ytr1SUCUi6J3L9dRFx5iH https://api.spotify.com/v1/audio-analysis/3Ytr1SUCUi6J3L9dRFx5iH 225850 4 Global
0.703 0.868 7 -4.661 0 0.0291 0.150000 1.32e-01 0.1040 0.732 121.030 audio_features 1NDxZ7cFAo481dtYWdrUnR spotify:track:1NDxZ7cFAo481dtYWdrUnR https://api.spotify.com/v1/tracks/1NDxZ7cFAo481dtYWdrUnR https://api.spotify.com/v1/audio-analysis/1NDxZ7cFAo481dtYWdrUnR 193613 4 Global
0.707 0.629 0 -4.581 0 0.0563 0.259000 1.60e-05 0.1380 0.444 122.863 audio_features 1x5sYLZiu9r5E43kMlt9f8 spotify:track:1x5sYLZiu9r5E43kMlt9f8 https://api.spotify.com/v1/tracks/1x5sYLZiu9r5E43kMlt9f8 https://api.spotify.com/v1/audio-analysis/1x5sYLZiu9r5E43kMlt9f8 212459 4 Global
0.747 0.864 8 -3.181 0 0.0599 0.024500 4.46e-05 0.0853 0.746 92.028 audio_features 2cnKEkpVUSV4wnjQiTWfH6 spotify:track:2cnKEkpVUSV4wnjQiTWfH6 https://api.spotify.com/v1/tracks/2cnKEkpVUSV4wnjQiTWfH6 https://api.spotify.com/v1/audio-analysis/2cnKEkpVUSV4wnjQiTWfH6 232787 4 Global
0.853 0.560 1 -4.961 1 0.0406 0.013000 0.00e+00 0.0944 0.860 134.066 audio_features 0KKkJNfGyhkQ5aFogxQAPU spotify:track:0KKkJNfGyhkQ5aFogxQAPU https://api.spotify.com/v1/tracks/0KKkJNfGyhkQ5aFogxQAPU https://api.spotify.com/v1/audio-analysis/0KKkJNfGyhkQ5aFogxQAPU 206693 4 Global
0.788 0.477 4 -7.348 1 0.0434 0.549000 0.00e+00 0.3490 0.862 94.983 audio_features 7MHN1aCFtLXjownGhvEQlF spotify:track:7MHN1aCFtLXjownGhvEQlF https://api.spotify.com/v1/tracks/7MHN1aCFtLXjownGhvEQlF https://api.spotify.com/v1/audio-analysis/7MHN1aCFtLXjownGhvEQlF 213027 4 Global
0.782 0.868 5 -1.715 0 0.0400 0.010600 2.52e-03 0.2900 0.876 96.042 audio_features 693iqPOQvhI7PobtR8CC8v spotify:track:693iqPOQvhI7PobtR8CC8v https://api.spotify.com/v1/tracks/693iqPOQvhI7PobtR8CC8v https://api.spotify.com/v1/audio-analysis/693iqPOQvhI7PobtR8CC8v 265747 4 Global
0.763 0.598 11 -6.865 1 0.0539 0.071400 0.00e+00 0.1120 0.184 140.987 audio_features 1yxgsra98r3qAtxqiGZPiX spotify:track:1yxgsra98r3qAtxqiGZPiX https://api.spotify.com/v1/tracks/1yxgsra98r3qAtxqiGZPiX https://api.spotify.com/v1/audio-analysis/1yxgsra98r3qAtxqiGZPiX 190678 4 Global
0.953 0.410 1 -6.543 1 0.0705 0.175000 0.00e+00 0.0768 0.726 121.074 audio_features 1sCxVKWImDZSZKvG0U9B23 spotify:track:1sCxVKWImDZSZKvG0U9B23 https://api.spotify.com/v1/tracks/1sCxVKWImDZSZKvG0U9B23 https://api.spotify.com/v1/audio-analysis/1sCxVKWImDZSZKvG0U9B23 214648 4 Global
0.743 0.359 1 -10.401 1 0.0794 0.199000 6.11e-03 0.1370 0.588 160.083 audio_features 3kxfsdsCpFgN412fpnW85Y spotify:track:3kxfsdsCpFgN412fpnW85Y https://api.spotify.com/v1/tracks/3kxfsdsCpFgN412fpnW85Y https://api.spotify.com/v1/audio-analysis/3kxfsdsCpFgN412fpnW85Y 326933 4 Global
0.741 0.667 10 -5.445 1 0.1340 0.057500 0.00e+00 0.1060 0.595 112.956 audio_features 1louJpMmzEicAn7lzDalPW spotify:track:1louJpMmzEicAn7lzDalPW https://api.spotify.com/v1/tracks/1louJpMmzEicAn7lzDalPW https://api.spotify.com/v1/audio-analysis/1louJpMmzEicAn7lzDalPW 223504 4 Global
0.736 0.795 1 -3.299 0 0.0545 0.498000 1.20e-06 0.2540 0.508 104.066 audio_features 7tr2za8SQg2CI8EDgrdtNl spotify:track:7tr2za8SQg2CI8EDgrdtNl https://api.spotify.com/v1/tracks/7tr2za8SQg2CI8EDgrdtNl https://api.spotify.com/v1/audio-analysis/7tr2za8SQg2CI8EDgrdtNl 230813 4 Global
0.736 0.449 1 -11.462 0 0.4250 0.330000 1.62e-04 0.0898 0.322 80.126 audio_features 152lZdxL1OR0ZMW6KquMif spotify:track:152lZdxL1OR0ZMW6KquMif https://api.spotify.com/v1/tracks/152lZdxL1OR0ZMW6KquMif https://api.spotify.com/v1/audio-analysis/152lZdxL1OR0ZMW6KquMif 219080 4 Global
0.576 0.390 10 -7.202 1 0.0297 0.491000 0.00e+00 0.1110 0.324 73.433 audio_features 0jdny0dhgjUwoIp5GkqEaA spotify:track:0jdny0dhgjUwoIp5GkqEaA https://api.spotify.com/v1/tracks/0jdny0dhgjUwoIp5GkqEaA https://api.spotify.com/v1/audio-analysis/0jdny0dhgjUwoIp5GkqEaA 230267 4 Global
0.679 0.634 5 -5.024 0 0.0654 0.232000 0.00e+00 0.1150 0.503 102.013 audio_features 0dA2Mk56wEzDgegdC6R17g spotify:track:0dA2Mk56wEzDgegdC6R17g https://api.spotify.com/v1/tracks/0dA2Mk56wEzDgegdC6R17g https://api.spotify.com/v1/audio-analysis/0dA2Mk56wEzDgegdC6R17g 210091 4 Global
0.334 0.617 6 -5.834 0 0.3830 0.334000 0.00e+00 0.1630 0.630 85.227 audio_features 1SJtlNRJDeYHioymcvsqev spotify:track:1SJtlNRJDeYHioymcvsqev https://api.spotify.com/v1/tracks/1SJtlNRJDeYHioymcvsqev https://api.spotify.com/v1/audio-analysis/1SJtlNRJDeYHioymcvsqev 216391 4 Global
0.543 0.677 11 -4.915 0 0.0993 0.014800 6.20e-06 0.1300 0.279 103.809 audio_features 2rb5MvYT7ZIxbKW5hfcHx8 spotify:track:2rb5MvYT7ZIxbKW5hfcHx8 https://api.spotify.com/v1/tracks/2rb5MvYT7ZIxbKW5hfcHx8 https://api.spotify.com/v1/audio-analysis/2rb5MvYT7ZIxbKW5hfcHx8 189440 4 Argentina
0.744 0.804 1 -6.327 1 0.0677 0.023100 0.00e+00 0.0494 0.456 104.823 audio_features 6De0lHrwBfPfrhorm9q1Xl spotify:track:6De0lHrwBfPfrhorm9q1Xl https://api.spotify.com/v1/tracks/6De0lHrwBfPfrhorm9q1Xl https://api.spotify.com/v1/audio-analysis/6De0lHrwBfPfrhorm9q1Xl 205715 4 Argentina
0.782 0.868 5 -1.715 0 0.0400 0.010600 2.52e-03 0.2900 0.876 96.042 audio_features 693iqPOQvhI7PobtR8CC8v spotify:track:693iqPOQvhI7PobtR8CC8v https://api.spotify.com/v1/tracks/693iqPOQvhI7PobtR8CC8v https://api.spotify.com/v1/audio-analysis/693iqPOQvhI7PobtR8CC8v 265747 4 Argentina
0.755 0.789 5 -4.502 1 0.1460 0.231000 0.00e+00 0.3510 0.734 93.973 audio_features 0qYTZCo5Bwh1nsUFGZP3zn spotify:track:0qYTZCo5Bwh1nsUFGZP3zn https://api.spotify.com/v1/tracks/0qYTZCo5Bwh1nsUFGZP3zn https://api.spotify.com/v1/audio-analysis/0qYTZCo5Bwh1nsUFGZP3zn 229849 4 Argentina
0.747 0.864 8 -3.181 0 0.0599 0.024500 4.46e-05 0.0853 0.746 92.028 audio_features 2cnKEkpVUSV4wnjQiTWfH6 spotify:track:2cnKEkpVUSV4wnjQiTWfH6 https://api.spotify.com/v1/tracks/2cnKEkpVUSV4wnjQiTWfH6 https://api.spotify.com/v1/audio-analysis/2cnKEkpVUSV4wnjQiTWfH6 232787 4 Argentina
0.708 0.693 6 -5.516 1 0.1380 0.246000 0.00e+00 0.1290 0.418 143.965 audio_features 22eADXu8DfOAUEDw4vU8qy spotify:track:22eADXu8DfOAUEDw4vU8qy https://api.spotify.com/v1/tracks/22eADXu8DfOAUEDw4vU8qy https://api.spotify.com/v1/audio-analysis/22eADXu8DfOAUEDw4vU8qy 271080 4 Argentina
0.792 0.819 5 -5.418 1 0.0867 0.030900 0.00e+00 0.3890 0.450 89.980 audio_features 209gZgcfLq2aUuu51vOWBl spotify:track:209gZgcfLq2aUuu51vOWBl https://api.spotify.com/v1/tracks/209gZgcfLq2aUuu51vOWBl https://api.spotify.com/v1/audio-analysis/209gZgcfLq2aUuu51vOWBl 205520 4 Argentina
0.766 0.620 6 -2.887 1 0.1270 0.104000 0.00e+00 0.0796 0.365 89.988 audio_features 6m2LNopVJKsvBB9l7Z1rwn spotify:track:6m2LNopVJKsvBB9l7Z1rwn https://api.spotify.com/v1/tracks/6m2LNopVJKsvBB9l7Z1rwn https://api.spotify.com/v1/audio-analysis/6m2LNopVJKsvBB9l7Z1rwn 161593 4 Argentina
0.735 0.482 7 -9.210 1 0.0508 0.205000 1.94e-04 0.0894 0.783 175.907 audio_features 0Szp49tpFasIjX04Mcsydp spotify:track:0Szp49tpFasIjX04Mcsydp https://api.spotify.com/v1/tracks/0Szp49tpFasIjX04Mcsydp https://api.spotify.com/v1/audio-analysis/0Szp49tpFasIjX04Mcsydp 193118 4 Argentina
0.726 0.705 6 -4.458 1 0.0636 0.247000 0.00e+00 0.4090 0.390 120.053 audio_features 66gNNRsKkmECPQUrvpMQtS spotify:track:66gNNRsKkmECPQUrvpMQtS https://api.spotify.com/v1/tracks/66gNNRsKkmECPQUrvpMQtS https://api.spotify.com/v1/audio-analysis/66gNNRsKkmECPQUrvpMQtS 231106 4 Argentina
0.825 0.652 1 -3.183 0 0.0802 0.581000 0.00e+00 0.0931 0.931 95.977 audio_features 7qiZfU4dY1lWllzX7mPBI3 spotify:track:7qiZfU4dY1lWllzX7mPBI3 https://api.spotify.com/v1/tracks/7qiZfU4dY1lWllzX7mPBI3 https://api.spotify.com/v1/audio-analysis/7qiZfU4dY1lWllzX7mPBI3 233713 4 Argentina
0.788 0.477 4 -7.348 1 0.0434 0.549000 0.00e+00 0.3490 0.862 94.983 audio_features 7MHN1aCFtLXjownGhvEQlF spotify:track:7MHN1aCFtLXjownGhvEQlF https://api.spotify.com/v1/tracks/7MHN1aCFtLXjownGhvEQlF https://api.spotify.com/v1/audio-analysis/7MHN1aCFtLXjownGhvEQlF 213027 4 Argentina
0.708 0.560 9 -7.132 1 0.1290 0.066800 0.00e+00 0.1110 0.411 163.043 audio_features 3rgjBiAMVGnxmsTDmUy8vb spotify:track:3rgjBiAMVGnxmsTDmUy8vb https://api.spotify.com/v1/tracks/3rgjBiAMVGnxmsTDmUy8vb https://api.spotify.com/v1/audio-analysis/3rgjBiAMVGnxmsTDmUy8vb 230520 4 Argentina
0.817 0.869 6 -4.791 1 0.1800 0.163000 2.26e-03 0.0497 0.560 96.029 audio_features 7lRsNbdOGykkMAgsqs4R1C spotify:track:7lRsNbdOGykkMAgsqs4R1C https://api.spotify.com/v1/tracks/7lRsNbdOGykkMAgsqs4R1C https://api.spotify.com/v1/audio-analysis/7lRsNbdOGykkMAgsqs4R1C 207200 4 Argentina
0.685 0.859 5 -2.595 0 0.0553 0.116000 0.00e+00 0.3170 0.886 176.018 audio_features 4okba5wu9mMLXx79DXLKi3 spotify:track:4okba5wu9mMLXx79DXLKi3 https://api.spotify.com/v1/tracks/4okba5wu9mMLXx79DXLKi3 https://api.spotify.com/v1/audio-analysis/4okba5wu9mMLXx79DXLKi3 204520 4 Argentina
0.743 0.855 5 -3.976 0 0.0436 0.141000 4.50e-03 0.0990 0.863 96.989 audio_features 7JNh1cfm0eXjqFVOzKLyau spotify:track:7JNh1cfm0eXjqFVOzKLyau https://api.spotify.com/v1/tracks/7JNh1cfm0eXjqFVOzKLyau https://api.spotify.com/v1/audio-analysis/7JNh1cfm0eXjqFVOzKLyau 202453 4 Argentina
0.685 0.731 5 -5.119 0 0.0930 0.204000 0.00e+00 0.0722 0.776 177.912 audio_features 4yN6xPLopmTLvc27pO9LIE spotify:track:4yN6xPLopmTLvc27pO9LIE https://api.spotify.com/v1/tracks/4yN6xPLopmTLvc27pO9LIE https://api.spotify.com/v1/audio-analysis/4yN6xPLopmTLvc27pO9LIE 221027 4 Argentina
0.639 0.869 11 -4.024 1 0.1470 0.270000 0.00e+00 0.0802 0.766 169.801 audio_features 5q2JbCNi4FcnglgPfxcV65 spotify:track:5q2JbCNi4FcnglgPfxcV65 https://api.spotify.com/v1/tracks/5q2JbCNi4FcnglgPfxcV65 https://api.spotify.com/v1/audio-analysis/5q2JbCNi4FcnglgPfxcV65 307910 4 Argentina
0.724 0.809 7 -4.960 1 0.0560 0.034500 0.00e+00 0.1690 0.495 95.037 audio_features 13X0XdLMOdtbXVtAj2ox4h spotify:track:13X0XdLMOdtbXVtAj2ox4h https://api.spotify.com/v1/tracks/13X0XdLMOdtbXVtAj2ox4h https://api.spotify.com/v1/audio-analysis/13X0XdLMOdtbXVtAj2ox4h 181048 4 Argentina
0.889 0.853 9 -4.260 1 0.2410 0.154000 1.07e-04 0.2050 0.916 93.022 audio_features 6qDF4wWL49CAVbgT7yuHl8 spotify:track:6qDF4wWL49CAVbgT7yuHl8 https://api.spotify.com/v1/tracks/6qDF4wWL49CAVbgT7yuHl8 https://api.spotify.com/v1/audio-analysis/6qDF4wWL49CAVbgT7yuHl8 201280 4 Argentina
0.660 0.786 2 -4.757 1 0.1700 0.209000 0.00e+00 0.1120 0.849 177.833 audio_features 4aWmUDTfIPGksMNLV2rQP2 spotify:track:4aWmUDTfIPGksMNLV2rQP2 https://api.spotify.com/v1/tracks/4aWmUDTfIPGksMNLV2rQP2 https://api.spotify.com/v1/audio-analysis/4aWmUDTfIPGksMNLV2rQP2 228200 4 Argentina
0.664 0.576 7 -5.395 0 0.0349 0.007300 6.28e-05 0.0912 0.123 134.934 audio_features 61HHDBLqF3AmSvLfHKNGd2 spotify:track:61HHDBLqF3AmSvLfHKNGd2 https://api.spotify.com/v1/tracks/61HHDBLqF3AmSvLfHKNGd2 https://api.spotify.com/v1/audio-analysis/61HHDBLqF3AmSvLfHKNGd2 233293 4 Argentina
0.760 0.838 7 -3.828 0 0.0529 0.547000 1.30e-06 0.0664 0.740 93.050 audio_features 5hEM0JchdVzQ5PwvSfITeX spotify:track:5hEM0JchdVzQ5PwvSfITeX https://api.spotify.com/v1/tracks/5hEM0JchdVzQ5PwvSfITeX https://api.spotify.com/v1/audio-analysis/5hEM0JchdVzQ5PwvSfITeX 210323 4 Argentina
0.832 0.772 10 -5.429 1 0.1000 0.055900 4.86e-04 0.4400 0.714 96.016 audio_features 3QwBODjSEzelZyVjxPOHdq spotify:track:3QwBODjSEzelZyVjxPOHdq https://api.spotify.com/v1/tracks/3QwBODjSEzelZyVjxPOHdq https://api.spotify.com/v1/audio-analysis/3QwBODjSEzelZyVjxPOHdq 209453 4 Argentina
0.635 0.713 11 -6.909 1 0.0937 0.228000 0.00e+00 0.0506 0.749 179.864 audio_features 0ERbK7qVqveCaBWIiYCrl3 spotify:track:0ERbK7qVqveCaBWIiYCrl3 https://api.spotify.com/v1/tracks/0ERbK7qVqveCaBWIiYCrl3 https://api.spotify.com/v1/audio-analysis/0ERbK7qVqveCaBWIiYCrl3 204701 4 Argentina
0.740 0.879 9 -2.251 0 0.1050 0.193000 8.25e-05 0.0928 0.951 103.710 audio_features 4qknM1pQz53QOyfDVTjcM9 spotify:track:4qknM1pQz53QOyfDVTjcM9 https://api.spotify.com/v1/tracks/4qknM1pQz53QOyfDVTjcM9 https://api.spotify.com/v1/audio-analysis/4qknM1pQz53QOyfDVTjcM9 226893 4 Argentina
0.683 0.691 8 -5.535 1 0.0432 0.243000 0.00e+00 0.1400 0.746 179.910 audio_features 3umS4y3uQDkqekNjVpiRUs spotify:track:3umS4y3uQDkqekNjVpiRUs https://api.spotify.com/v1/tracks/3umS4y3uQDkqekNjVpiRUs https://api.spotify.com/v1/audio-analysis/3umS4y3uQDkqekNjVpiRUs 219507 4 Argentina
0.694 0.815 2 -4.328 1 0.1200 0.229000 0.00e+00 0.0924 0.826 88.931 audio_features 5CtI0qwDJkDQGwXD1H1cLb spotify:track:5CtI0qwDJkDQGwXD1H1cLb https://api.spotify.com/v1/tracks/5CtI0qwDJkDQGwXD1H1cLb https://api.spotify.com/v1/audio-analysis/5CtI0qwDJkDQGwXD1H1cLb 228827 4 Argentina
0.739 0.688 9 -10.246 1 0.1570 0.551000 1.18e-03 0.1010 0.586 169.829 audio_features 6SIrNxmmdbv1KUbFBu1PaN spotify:track:6SIrNxmmdbv1KUbFBu1PaN https://api.spotify.com/v1/tracks/6SIrNxmmdbv1KUbFBu1PaN https://api.spotify.com/v1/audio-analysis/6SIrNxmmdbv1KUbFBu1PaN 231602 4 Argentina
0.684 0.823 9 -3.297 0 0.0773 0.074400 0.00e+00 0.1110 0.645 91.048 audio_features 7nKBxz47S9SD79N086fuhn spotify:track:7nKBxz47S9SD79N086fuhn https://api.spotify.com/v1/tracks/7nKBxz47S9SD79N086fuhn https://api.spotify.com/v1/audio-analysis/7nKBxz47S9SD79N086fuhn 208163 4 Argentina
0.685 0.799 0 -5.945 0 0.0542 0.122000 2.44e-03 0.3740 0.875 105.069 audio_features 3VSt7R9LHTomKGP1RhkvuT spotify:track:3VSt7R9LHTomKGP1RhkvuT https://api.spotify.com/v1/tracks/3VSt7R9LHTomKGP1RhkvuT https://api.spotify.com/v1/audio-analysis/3VSt7R9LHTomKGP1RhkvuT 199776 4 Argentina
0.489 0.962 0 -2.597 1 0.2150 0.027700 6.20e-06 0.1280 0.507 104.563 audio_features 2Vdub5mY4lad7w64bFPUez spotify:track:2Vdub5mY4lad7w64bFPUez https://api.spotify.com/v1/tracks/2Vdub5mY4lad7w64bFPUez https://api.spotify.com/v1/audio-analysis/2Vdub5mY4lad7w64bFPUez 194942 4 Argentina
0.548 0.650 8 -5.827 0 0.0591 0.219000 0.00e+00 0.2250 0.557 144.937 audio_features 3A7qX2QjDlPnazUsRk5y0M spotify:track:3A7qX2QjDlPnazUsRk5y0M https://api.spotify.com/v1/tracks/3A7qX2QjDlPnazUsRk5y0M https://api.spotify.com/v1/audio-analysis/3A7qX2QjDlPnazUsRk5y0M 194897 4 Argentina
0.761 0.838 4 -3.073 0 0.0502 0.400000 0.00e+00 0.1760 0.717 93.974 audio_features 3AEZUABDXNtecAOSC1qTfo spotify:track:3AEZUABDXNtecAOSC1qTfo https://api.spotify.com/v1/tracks/3AEZUABDXNtecAOSC1qTfo https://api.spotify.com/v1/audio-analysis/3AEZUABDXNtecAOSC1qTfo 222560 4 Argentina
0.819 0.457 0 -6.962 0 0.1350 0.222000 0.00e+00 0.1280 0.279 115.997 audio_features 4UG962ViiLqoUyx0RjCcwP spotify:track:4UG962ViiLqoUyx0RjCcwP https://api.spotify.com/v1/tracks/4UG962ViiLqoUyx0RjCcwP https://api.spotify.com/v1/audio-analysis/4UG962ViiLqoUyx0RjCcwP 324828 4 Argentina
0.696 0.817 1 -3.862 1 0.1090 0.075000 0.00e+00 0.1870 0.779 98.064 audio_features 6kex4EBAj0WHXDKZMEJaaF spotify:track:6kex4EBAj0WHXDKZMEJaaF https://api.spotify.com/v1/tracks/6kex4EBAj0WHXDKZMEJaaF https://api.spotify.com/v1/audio-analysis/6kex4EBAj0WHXDKZMEJaaF 216409 4 Argentina
0.771 0.906 7 -5.884 1 0.0506 0.020800 5.54e-05 0.3040 0.415 111.640 audio_features 2q3B7GLCEA4uYvuo2g5P82 spotify:track:2q3B7GLCEA4uYvuo2g5P82 https://api.spotify.com/v1/tracks/2q3B7GLCEA4uYvuo2g5P82 https://api.spotify.com/v1/audio-analysis/2q3B7GLCEA4uYvuo2g5P82 155350 4 Argentina
0.801 0.551 2 -6.987 1 0.0427 0.115000 0.00e+00 0.1130 0.861 124.009 audio_features 0imzSFFJDCdKruduJHFN6A spotify:track:0imzSFFJDCdKruduJHFN6A https://api.spotify.com/v1/tracks/0imzSFFJDCdKruduJHFN6A https://api.spotify.com/v1/audio-analysis/0imzSFFJDCdKruduJHFN6A 197590 4 Argentina
0.776 0.669 11 -4.933 1 0.0638 0.142000 0.00e+00 0.2190 0.646 91.012 audio_features 5J1c3M4EldCfNxXwrwt8mT spotify:track:5J1c3M4EldCfNxXwrwt8mT https://api.spotify.com/v1/tracks/5J1c3M4EldCfNxXwrwt8mT https://api.spotify.com/v1/audio-analysis/5J1c3M4EldCfNxXwrwt8mT 228467 4 Argentina
0.745 0.921 0 -2.674 1 0.0820 0.089700 0.00e+00 0.1780 0.645 92.973 audio_features 5i50gKdLAjjIr7UxRT5IVy spotify:track:5i50gKdLAjjIr7UxRT5IVy https://api.spotify.com/v1/tracks/5i50gKdLAjjIr7UxRT5IVy https://api.spotify.com/v1/audio-analysis/5i50gKdLAjjIr7UxRT5IVy 223613 4 Argentina
0.761 0.820 1 -4.003 1 0.0623 0.125000 2.10e-05 0.1830 0.619 88.997 audio_features 3BY2mafsbsoKGqS380Xnuz spotify:track:3BY2mafsbsoKGqS380Xnuz https://api.spotify.com/v1/tracks/3BY2mafsbsoKGqS380Xnuz https://api.spotify.com/v1/audio-analysis/3BY2mafsbsoKGqS380Xnuz 211627 4 Argentina
0.588 0.682 11 -7.169 0 0.1730 0.085100 2.69e-05 0.0840 0.938 205.643 audio_features 1MpKZi1zTXpERKwxmOu1PH spotify:track:1MpKZi1zTXpERKwxmOu1PH https://api.spotify.com/v1/tracks/1MpKZi1zTXpERKwxmOu1PH https://api.spotify.com/v1/audio-analysis/1MpKZi1zTXpERKwxmOu1PH 195274 4 Argentina
0.774 0.626 3 -4.432 0 0.0432 0.096900 3.12e-05 0.0848 0.758 100.041 audio_features 4iLqG9SeJSnt0cSPICSjxv spotify:track:4iLqG9SeJSnt0cSPICSjxv https://api.spotify.com/v1/tracks/4iLqG9SeJSnt0cSPICSjxv https://api.spotify.com/v1/audio-analysis/4iLqG9SeJSnt0cSPICSjxv 211475 4 Argentina
0.772 0.909 6 -3.225 0 0.1660 0.256000 0.00e+00 0.2550 0.679 96.031 audio_features 3dQDid3IUNhZy1OehIfYfE spotify:track:3dQDid3IUNhZy1OehIfYfE https://api.spotify.com/v1/tracks/3dQDid3IUNhZy1OehIfYfE https://api.spotify.com/v1/audio-analysis/3dQDid3IUNhZy1OehIfYfE 238800 4 Argentina
0.690 0.872 11 -2.984 0 0.0588 0.226000 0.00e+00 0.0858 0.720 94.000 audio_features 4N1c5rmWOzRmB9SMacr5wB spotify:track:4N1c5rmWOzRmB9SMacr5wB https://api.spotify.com/v1/tracks/4N1c5rmWOzRmB9SMacr5wB https://api.spotify.com/v1/audio-analysis/4N1c5rmWOzRmB9SMacr5wB 252200 4 Argentina
0.852 0.773 8 -2.921 0 0.0776 0.187000 3.05e-05 0.1590 0.908 102.034 audio_features 6mICuAdrwEjh6Y6lroV2Kg spotify:track:6mICuAdrwEjh6Y6lroV2Kg https://api.spotify.com/v1/tracks/6mICuAdrwEjh6Y6lroV2Kg https://api.spotify.com/v1/audio-analysis/6mICuAdrwEjh6Y6lroV2Kg 195840 4 Argentina
0.723 0.889 0 -4.017 1 0.0939 0.067300 0.00e+00 0.3630 0.711 101.032 audio_features 1AkTW13ysu0AJrwuM6UY0I spotify:track:1AkTW13ysu0AJrwuM6UY0I https://api.spotify.com/v1/tracks/1AkTW13ysu0AJrwuM6UY0I https://api.spotify.com/v1/audio-analysis/1AkTW13ysu0AJrwuM6UY0I 224320 4 Argentina
0.737 0.709 8 -6.889 0 0.0449 0.333000 0.00e+00 0.2890 0.537 125.997 audio_features 6r46lnXFbE9fr2d3KNaGbe spotify:track:6r46lnXFbE9fr2d3KNaGbe https://api.spotify.com/v1/tracks/6r46lnXFbE9fr2d3KNaGbe https://api.spotify.com/v1/audio-analysis/6r46lnXFbE9fr2d3KNaGbe 234829 4 Argentina
0.748 0.884 10 -3.556 1 0.0501 0.090200 0.00e+00 0.3610 0.653 95.046 audio_features 4z3GJkrtH97Bj6fRta983T spotify:track:4z3GJkrtH97Bj6fRta983T https://api.spotify.com/v1/tracks/4z3GJkrtH97Bj6fRta983T https://api.spotify.com/v1/audio-analysis/4z3GJkrtH97Bj6fRta983T 193159 4 Argentina
0.761 0.829 0 -3.203 0 0.0681 0.167000 0.00e+00 0.1890 0.820 92.033 audio_features 6stYbAJgTszHAHZMPxWWCY spotify:track:6stYbAJgTszHAHZMPxWWCY https://api.spotify.com/v1/tracks/6stYbAJgTszHAHZMPxWWCY https://api.spotify.com/v1/audio-analysis/6stYbAJgTszHAHZMPxWWCY 252003 4 Argentina

Finally, I have computed the mean of each country´s audio features using the aggregate function. The resulting dataframe contains the audio features for each country as the mean of the Top 50 tracks.

Features_df_aggr <- aggregate(Features_df[, c(1:11,17)], list(Features_df$source), mean)
names(Features_df_aggr) <- c("Country", "danceability", "energy", "key", "loudness", "mode", "speechiness", "acousticness", "instrumentalness", "liveness", "valence", "tempo", "duration_ms")
options(knitr.table.format = "html")
options(width = 12)
kable(Features_df_aggr) %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), font_size = 12) %>%
scroll_box(width = "720px", height = "350px")
Country danceability energy key loudness mode speechiness acousticness instrumentalness liveness valence tempo duration_ms
Global 0.72306 0.66698 5.04 -5.39570 0.46 0.098908 0.1520612 0.0072217 0.138980 0.593540 112.6895 214174.9
Argentina 0.72778 0.75998 5.74 -4.77270 0.56 0.092020 0.1764100 0.0002811 0.178598 0.670320 117.3519 219151.5
Australia 0.70712 0.66582 5.32 -5.45078 0.46 0.095126 0.1599314 0.0112925 0.137944 0.554220 112.4833 212461.2
Austria 0.70280 0.71172 4.98 -5.21274 0.44 0.091718 0.1454967 0.0072528 0.136540 0.607240 112.7422 202450.6
Belgium 0.73000 0.71484 5.60 -5.14098 0.46 0.097378 0.1478912 0.0073051 0.134736 0.583412 115.3720 204349.8
Bolivia 0.72024 0.75972 5.36 -4.63920 0.60 0.096448 0.1877582 0.0044053 0.182422 0.665660 114.6844 219539.9
Brazil 0.68588 0.70472 6.14 -4.88710 0.58 0.113026 0.2726898 0.0086949 0.243646 0.651100 123.8542 192143.0
Canada 0.72948 0.62670 5.22 -5.80772 0.44 0.119608 0.1533494 0.0067501 0.139340 0.541540 114.4444 214364.4
Chile 0.72960 0.75038 5.72 -4.87056 0.56 0.097012 0.2065100 0.0003863 0.164928 0.652760 115.9052 228175.9
Colombia 0.71848 0.76304 5.60 -4.55296 0.62 0.093076 0.1799268 0.0001157 0.184410 0.674020 114.0239 222885.5
CostaRica 0.72160 0.72188 5.54 -4.81014 0.52 0.091904 0.1665008 0.0004666 0.156910 0.652280 118.2872 222303.2
CzechRepublic 0.69640 0.70122 5.38 -4.93404 0.44 0.090222 0.1219820 0.0071241 0.132448 0.583140 112.5297 206995.3
Denmark 0.72938 0.69284 5.74 -5.38064 0.44 0.090170 0.1629708 0.0075264 0.136476 0.591140 115.6873 203477.8
DominicanRepublic 0.75294 0.70194 5.24 -5.47164 0.56 0.096130 0.2088880 0.0219590 0.174516 0.583260 118.4104 230493.6
Ecuador 0.72684 0.77970 5.74 -4.42592 0.60 0.091272 0.1849980 0.0002071 0.178548 0.685680 114.4883 220000.2
ElSalvador 0.72254 0.72770 5.64 -4.76184 0.50 0.090120 0.1780234 0.0045278 0.159506 0.617320 117.5215 222466.0
Finland 0.69710 0.74272 5.54 -4.77856 0.38 0.101518 0.1297894 0.0045623 0.193862 0.618980 119.4300 199395.2
France 0.72406 0.70902 4.58 -5.33496 0.40 0.118288 0.2079066 0.0075791 0.130100 0.585300 118.4740 210228.2
Germany 0.70520 0.70666 5.18 -5.40200 0.42 0.100990 0.1618307 0.0075784 0.128832 0.582800 114.0201 205772.9
Greece 0.72038 0.68160 5.54 -5.27012 0.40 0.105560 0.1262072 0.0075640 0.131612 0.576300 115.4823 205789.0
Guatemala 0.71870 0.73558 5.54 -4.99372 0.58 0.085980 0.1904380 0.0002304 0.172412 0.647060 118.3756 227724.4
Honduras 0.73398 0.71090 5.56 -5.11448 0.52 0.089554 0.1994940 0.0005534 0.165646 0.626140 118.2490 233859.9
HongKong 0.68128 0.64420 5.44 -5.51762 0.52 0.087206 0.2032628 0.0070451 0.134352 0.546820 118.5979 217183.3
Hungary 0.70426 0.69000 5.20 -5.09096 0.40 0.092824 0.1323380 0.0075021 0.134386 0.578820 113.0934 209573.0
Iceland 0.73706 0.63078 4.90 -6.09796 0.44 0.115908 0.1418150 0.0049734 0.143538 0.544632 118.7113 211691.4
Indonesia 0.68280 0.64652 4.80 -5.46218 0.54 0.079294 0.2087740 0.0079035 0.127040 0.549140 115.6884 216436.3
Ireland 0.70560 0.70616 5.08 -4.91402 0.48 0.089462 0.1419776 0.0070617 0.148646 0.560760 113.5242 207388.9
Italy 0.70894 0.73186 5.84 -5.08746 0.46 0.081182 0.1269734 0.0069528 0.122930 0.615880 117.8851 206689.5
Japan 0.70338 0.67870 5.14 -5.12806 0.54 0.081808 0.1577940 0.0073020 0.151474 0.566000 117.5607 216631.5
Latvia 0.71952 0.67800 5.12 -5.30870 0.44 0.094348 0.1241952 0.0076854 0.135972 0.531542 115.4168 212558.4
Lithuania 0.71490 0.67034 5.38 -5.42242 0.42 0.094424 0.1379652 0.0072523 0.131472 0.538622 113.7656 211591.3
Malaysia 0.67010 0.63940 4.86 -5.52246 0.50 0.087834 0.1518716 0.0070464 0.142844 0.555740 118.1268 209413.2
Mexico 0.71756 0.72924 5.84 -4.80672 0.58 0.078532 0.1826086 0.0044398 0.160540 0.667620 114.5652 218198.0
Netherlands 0.74148 0.72778 4.88 -4.99544 0.46 0.118174 0.1596662 0.0075748 0.148534 0.608980 112.3498 205605.6
NewZealand 0.71450 0.65072 5.34 -5.59214 0.42 0.096364 0.1599574 0.0071722 0.137654 0.571800 111.8506 214714.7
Norway 0.67118 0.69100 5.06 -5.40912 0.42 0.089116 0.1243720 0.0076048 0.126668 0.544648 111.9211 207352.2
Panama 0.72670 0.73536 5.54 -4.89514 0.58 0.092768 0.1786580 0.0004956 0.162542 0.638260 116.7577 227573.6
Paraguay 0.73770 0.73346 5.74 -4.89534 0.56 0.096192 0.2192098 0.0006405 0.168108 0.625160 115.9627 226358.5
Peru 0.73658 0.76692 5.54 -4.55018 0.62 0.092396 0.1911520 0.0002072 0.165450 0.668400 114.7702 230013.4
Phillippines 0.67598 0.59818 5.18 -5.98022 0.70 0.076178 0.2264378 0.0075078 0.136308 0.559500 113.5197 215312.6
Poland 0.72106 0.66876 5.38 -6.00992 0.38 0.123360 0.1884447 0.0104707 0.148454 0.559436 113.8099 212686.8
Portugal 0.70980 0.67312 4.78 -5.38020 0.42 0.101880 0.1391218 0.0050565 0.139272 0.549940 115.1651 217133.3
Singapore 0.69704 0.66572 5.12 -5.27414 0.48 0.094614 0.1352752 0.0070468 0.136460 0.573980 115.5357 206427.3
Slovakia 0.69604 0.69550 5.44 -5.09202 0.50 0.089882 0.1226472 0.0071241 0.136884 0.561722 118.2353 206220.9
Spain 0.72088 0.77862 5.02 -4.41050 0.60 0.084552 0.1886326 0.0044058 0.178966 0.687440 111.7777 215129.5
Sweden 0.69452 0.69956 5.36 -5.15540 0.44 0.083044 0.1334048 0.0157034 0.125188 0.545048 110.1106 203910.7
Switzerland 0.70324 0.69950 5.12 -5.10466 0.46 0.099124 0.1256512 0.0070477 0.137276 0.570240 111.4683 207657.5
Taiwan 0.64690 0.61716 4.96 -6.11654 0.60 0.072616 0.2456396 0.0070498 0.122712 0.507260 125.3408 222640.8
Turkey 0.70390 0.70914 4.78 -5.52118 0.38 0.099094 0.1250178 0.0266812 0.164064 0.593480 115.0279 215549.6
UnitedKingdom 0.68242 0.72096 4.94 -4.87004 0.46 0.098254 0.1250336 0.0071444 0.144480 0.569340 116.0574 208696.3
UnitedStates 0.75302 0.62112 4.92 -5.96362 0.48 0.117930 0.1568819 0.0050662 0.149514 0.539260 119.4343 215526.6
Uruguay 0.71540 0.76336 6.02 -4.82410 0.58 0.093500 0.1745640 0.0002917 0.181168 0.676180 119.3460 213594.0

Audio features description

The description of each feature from the Spotify Web API Guidance can be found below:

  • Danceability: Describes 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.

  • Energy: Is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy, while a Bach prelude scores low on the scale. Perceptual features contributing to this attribute include dynamic range, perceived loudness, timbre, onset rate, and general entropy.

  • Key: The key the track is in. Integers map to pitches using standard Pitch Class notation. E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on.

  • Loudness: The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing relative loudness of tracks. Loudness is the quality of a sound that is the primary psychological correlate of physical strength (amplitude). Values typical range between -60 and 0 db.

  • Mode: Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0.

  • Speechiness: Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording (e.g. talk show, audio book, poetry), the closer to 1.0 the attribute value. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, either in sections or layered, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks.

  • Acousticness: A confidence measure from 0.0 to 1.0 of whether the track is acoustic. 1.0 represents high confidence the track is acoustic.

  • Instrumentalness: Predicts whether a track contains no vocals. “Ooh” and “aah” sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly “vocal”. The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0.

  • Liveness: Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihood that the track is live.

  • Valence: A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).

  • Tempo: The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration.

  • Duration_ms: The duration of the track in milliseconds.

Data Visualisation

Radar chart

Radar chart (Ten countries)

A radar chart is useful to compare the musical taste of the countries in a more visual way. The first visualisation is an R implementation of the radar chart from the chart.js javascript library and evaluates the audio features for 10 selected countries.

First, I normalised the values to be from 0 to 1. This will help to make the chart more clear and readable.

Features_df_aggr_norm <- cbind(Features_df_aggr[1], 
                                     apply(Features_df_aggr[-1],2,
                                           function(x){(x-min(x)) / diff(range(x))}))

Next, an interactive radar chart can be plotted. It displays data set labels when hovering over each radial line, showing the value for the selected feature.

library(radarchart)
library(tidyr)
Features_df_aggr_10 <- Features_df_aggr[Features_df_aggr$Country %in% c("Global", "Argentina", "Brazil", "Canada", "France", "Germany", "HongKong", "Spain", "Taiwan", "UnitedKingdom", "UnitedStates"),]

Features_df_aggr_norm_10 <- cbind(Features_df_aggr_10[1], 
                                        apply(Features_df_aggr_10[-1],2,
                                              function(x){(x-min(x)) / diff(range(x))})) 

radarDF <- gather(Features_df_aggr_norm_10, key=Attribute, value=Score, -Country) %>%
  spread(key=Country, value=Score)

chartJSRadar(scores = radarDF,
             scaleStartValue = -1, 
             maxScale =1, 
             showToolTipLabel = TRUE)

Shiny App

To see how audio features change with the country, we must look at far more country´s playlists than the ten included in the radar chart above. In order to do so, I created an interactive Shiny App that contains the Global and the 51 other country´s features. It allows to explore any country and compare their features against any other country.

Click here to open the Shiny App.

Cluster Analysis

Another way to find out the differences between countries in their musical taste is grouping them in clusters. The general idea of a clustering algorithm is to divide a given dataset into multiple groups on the basis of similarity in the data. In this case, countries will be grouped in different clusters according to their music preferences.

Prior to clustering data, it is important to rescale the numeric variables of the dataset. After that, I kept the countries as the row names to be able to show them as labels in the plot.

scaled.features <- scale(Features_df_aggr[-1])
rownames(scaled.features) <- Features_df_aggr$Country

I applied the K-Means clustering method, which is one of the most popular techniques of unsupervised statistical learning methods. It is an unsupervised method because is performed on a set of variables X1, X2, Xp with no associated response Y, so there is no outcome to be predicted. It aims to partition n observations into k cluster in which each observation belongs to the cluster with the nearest mean.

Now that we apply the the K-Means algorithm for each country, we can plot a two-dimensional view of the data. The x-axis and y-axis correspond to the first and second component, and the eigenvectors (represented by red arrows) indicate the directional influence each variable has on the principal components. Let´s have a look at the clusters that result from applying the K-Means algorithm to our dataset.

library(ggfortify)
library(ggthemes)
set.seed(5000)

k_means <- kmeans(scaled.features, 3)
kmeans_plot <- autoplot(k_means, 
              main = "K-means clustering", 
              data = scaled.features,
              loadings = TRUE, loadings.colour = "#CC0000",loadings.label.colour = "#CC0000", loadings.label = TRUE, loadings.label.size = 3,  loadings.label.repel=T,
              label.size = 3, label.repel = T) + scale_fill_manual(values = c("#000066", "#9999CC", "#66CC99"))+ scale_color_manual(values = c("#000066", "#9999CC", "#66CC99")) + theme(plot.title=element_text(size=18, face="bold"))

Click to view plot in new window.

I have also plotted another radar chart containing the features for each cluster. It is useful to compare the attributes of the songs that each cluster listen to.

Features_df_aggr_norm_52 <- cbind(Features_df_aggr[1], 
                                      apply(Features_df_aggr[-1],2,
                                            scale)) 
library(radarchart)
library(tidyr)
cluster_centers <- as.data.frame(k_means$centers)
cluster <- c("Cluster 1", "Cluster 2", "Cluster 3")
cluster_centers <- cbind(cluster, cluster_centers)
radarDF2 <- gather(cluster_centers, key=Attribute, value=Score, -cluster) %>%
  spread(key=cluster, value=Score)
#we change the colours according to clusters
colMatrix = matrix(c(c(4,24,102), c(135,133,193), c(87,196,135)), nrow = 3)
#chart
chartJSRadar(scores = radarDF2,
             scaleStartValue = -4, 
             maxScale =1.5, 
             showToolTipLabel = TRUE,
             colMatrix = colMatrix)



The graphic representation of the clusters in a world map reveals that Cluster 1 contains Asian countries, Cluster 2 is made of Latin American countries and Spain and Cluster 3 includes North America, most Europe and Oceania.

op <- options(gvis.plot.tag = "chart")
library(googleVis)
countries_clusters <- read_delim("~/Documents/BlogDir/blogdown_source/content/post/countries-clusters.csv", 
                                 ";", escape_double = FALSE, trim_ws = TRUE)
WorldMap=gvisGeoChart(data = countries_clusters,locationvar="locationvar", colorvar="Cluster",
                 options=list(projection="kavrayskiy-vii",
                              colorAxis="{colors:['#000066', '#9999CC', '#66CC99']}",
                              width = 400, height = 200))



The first K-Means plot shows 3 highly differentiated clusters and the location seems to be a determining factor. Nearby countries are grouped in clusters and, apparently, share similar musical preferences.

  • The first cluster contains Asian countries, such as Taiwan, Phillippines, Malaysia, Hong Kong or Indonesia. These countries listen acoustic, instrumental and with higher tempo (beats per minute) tracks.

  • The second cluster is formed by Latin American and Spanish-speaking countries such as Spain, Brazil, Chile, Colombia or Uruguay. These countries prefer to listen optimistic, danceable, energetic and strong (or loud) music.

  • The third cluster contains the other countries, such as Germany, United Kingdom, Australia, United States or Canada. These countries prefer songs that contain a higher number of spoken words and speech-like sections.

Analysis by Feature (Diverging bar plot)

The following charts show the values for each feature for every country. The code below details the process of making the danceability diverging bar plot. The code for the other features has been omitted but each feature´s plot is displayed below in a slideshow.

library(stringr)
# Converting cluster to vector
clusters <- as.vector(k_means$cluster)
clusters <- str_replace_all(clusters, "1", "Cluster 1")
clusters <- str_replace_all(clusters, "2", "Cluster 2")
clusters <- str_replace_all(clusters, "3", "Cluster 3")
clusters[1] <- "Global"
Features_df_aggr_norm_52 <- cbind(Features_df_aggr_norm_52, cluster = clusters)
# Showing only Danceability
danceability_subset <- Features_df_aggr_norm_52[,c("Country","danceability", "cluster")]
library(ggplot2)
# Showing only Danceability
danceability_subset <- danceability_subset[order(danceability_subset$danceability, decreasing = TRUE), ]

danceability_plot <- ggplot(danceability_subset, aes(x = reorder(Country, danceability), y = danceability, label=danceability)) + xlab("Country") + ylab("Danceability") + geom_bar(stat='identity', aes(fill=cluster), width = .5) + scale_fill_manual(name="Cluster",
                        labels = c("Cluster 1", "Cluster 2", "Cluster 3", "Global"), 
                        values = c("Cluster 1"="#000066", "Cluster 2"="#9999CC", "Cluster 3" = "#66CC99", "Global" = "indianred2")) + labs(title="Danceability feature", subtitle= "Diverging Bars") + coord_flip()
Diverging bar plot

Shared Tracks (Global - Each Country)

This section focuses on counting the number of tracks in each country which are present on the Global Playlist. The goal is to find which country has more tracks that are present on the Global playlist.

PlaylistSongs2 <- PlaylistSongs[,2:4]
GlobalSongs <- PlaylistSongs2[1:50,]
PlaylistSongs2 <- PlaylistSongs2[-c(1:50),]

PlaylistSongs2$InGlobalPlaylist <- PlaylistSongs2$id %in% GlobalSongs$id

hits_by_country <- group_by(PlaylistSongs2, Country) %>%
  summarize(InGlobalPlaylist = sum(InGlobalPlaylist))
hits_by_country <- cbind(hits_by_country, cluster = clusters[2:52])

hits_by_country <- hits_by_country[order(hits_by_country$InGlobalPlaylist, decreasing = TRUE), ]

ggplot(hits_by_country, aes(x = reorder(Country, InGlobalPlaylist), y = InGlobalPlaylist, label=InGlobalPlaylist)) + xlab("Country") + ylab("No. of tracks of Global Playlist") + geom_bar(stat='identity', aes(fill=cluster), width = .5) + scale_fill_manual(name="Cluster",
                        labels = c("Cluster 1", "Cluster 2", "Cluster 3", "Global"), 
                        values = c("Cluster 1"="#000066", "Cluster 2"="#9999CC", "Cluster 3" = "#66CC99")) + labs(title="No. Of Tracks of Global Playlist") + coord_flip()

As can be seen in the example above, Cluster 3 (especially New Zealand, Switzerland or Australia) includes the greater number of countries that share songs with the Global playlist. Cluster 2 (with Asian countries) and especially Cluster 3 (Spanish-speaking countries and Brazil) share less songs with the Global playlist than the first cluster.

comments powered by Disqus