tiagomendesdantas/Rspotify

Using Rspotify to access genres for Multiple Artists

Polly7451 opened this issue · 1 comments

Hey @tiagomendesdantas

I am pretty new to both R and GitHub so forgive me if I have the wrong end of the stick and this isn't the right format or forum for asking for questions and Advise - which I am definitely in need of.

I am using RStudio 3.4.4 on a windows 10 machine, and I have got myself in a pickle

I have got a vector of artist names and I am trying to get genre information for them all on spotify. I have successfully set up the API and the RSpotify package is working as expected.

I am trying to build up to create a function but I am failing pretty early on.

So far i have the following but it is returning unexpected results

  len <- nrow(Artist_Nam)
  artist_info <- character(artist)      

 for(i in 1:len){
  ifelse(nrow(searchArtist(Artist_Nam$ArtistName[i], token = keys))>=1,       
 artist_info[i] <- searchArtist(Artist_Nam$ArtistName[i], token = keys)$genres[1],
 artist_info[i] <- "")

 }
artist_info

I was expecting this to return a list of genres, and artists where there is not a match on spotify I would have an empty entry ""

Instead what is returned is a list and entries are populated with genres and on inspection these genres are correct and there are "" where there is no match however, something odd happens from [73] on wards (I have over 3,000 artists), the list now only returns "". despite when i actually look into this using the searchArtist() manually there are matches.

I think this is my dodgy R appose to my inability to use your package, but if you have any idea, suggestions or advise, it would be greatly appreciated.

Thanks,

Polly

Just an API limit - i added a delay and everything is dandy.

Sorry to bother you!