Skip to content

Instantly share code, notes, and snippets.

@JosiahParry
Created June 24, 2019 16:24
Show Gist options
  • Save JosiahParry/f5e8384dd9e8f8903640bb7ae319807c to your computer and use it in GitHub Desktop.
Save JosiahParry/f5e8384dd9e8f8903640bb7ae319807c to your computer and use it in GitHub Desktop.
Create version of `get_track_audio_features()` which takes artist name and title.
# create function for getting song features
track_audio_features <- function(artist, title, type = "track") {
search_results <- search_spotify(paste(artist, title), type = type)
track_audio_feats <- get_track_audio_features(search_results$id[[1]]) %>%
dplyr::select(-id, -uri, -track_href, -analysis_url)
return(track_audio_feats)
}
# create a version of this function which can handle errors
possible_af <- possibly(track_audio_features, otherwise = tibble())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment