This document will try to show off the package “spotifyr” in r for someone who doesn’t really know how to use r. “spotifyr” is a package on CRAN that allows a user to perform analytics on Spotify’s data. You might be interested in your all time most played artist, or the beatles most dancable song, and through “spotifyr’ you can.
first you will have to go on to the website https://developer.spotify.com/dashboard/login and log on to your spotify (does not have to be a paid subscription). Then, we will start developing an app on their website, and after we name it, it will give us an id key and a secret key. We will use that in the future code.
#library(spotifyr)
#library(tidyverse)
#id = "Enter id key here"
#secret = "Enter Secret key here"
#Sys.setenv(SPOTIFY_CLIENT_ID = id)
#Sys.setenv(SPOTIFY_CLIENT_SECRET = secret)
#access_token <- get_spotify_access_token()
A feature that is pretty cool is the get_artist_audio_features function. It call all of the information for a certain artist. For this example I picked Jack Johnson because he is one of my all time favorites.
Jack_Johnson <- get_artist_audio_features('Jack Johnson')
This function is counting the key of all of Jack’s songs. Seems her uses GDC the most.
Jack_Johnson %>%
count(key_mode, sort = TRUE) %>%
head(5)
## key_mode n
## 1 G major 48
## 2 D major 47
## 3 C major 42
## 4 B major 29
## 5 F major 28
This is an interesting function. Valence is spotify’s messure of how positive a song is. This function will show Jack’s Top 5 happiest/most positive songs.
Jack_Johnson %>%
arrange(-valence) %>%
select(track_name, valence) %>%
head(5)
## track_name valence
## 1 Mudfootball (For Moe Lerner) 0.973
## 2 Mudfootball (For Moe Lerner) 0.971
## 3 Gather 0.967
## 4 Flake 0.966
## 5 Flake 0.966
This is an interesting function. Valence is spotify’s messure of how positive a song is. This function will show Jack’s Top 5 happiest/most positive songs.