I'm trying to loop through a function -- get_artists() -- where the first argument is required to be string within quotations. The argument is supposed to be an artist's name, such as "Radiohead". However, since I'm looping, I need to set it to be my variable name, as below.
get_album_data <- function(x) {
get_artists(mydata$Artist[x], return_closest_artist = TRUE) %>%
get_albums(mydata$Album[x]) %>%
get_album_tracks()
}
This won't work though, since mydata$Artist[x] isn't in quotes. And if I do:
get_album_data <- function(x) {
get_artists("mydata$Artist[x]", return_closest_artist = TRUE) %>%
get_albums(mydata$Album[x]) %>%
get_album_tracks()
}
It'll act as if mydata$Artist[x] is the name of the artist.
Any ideas? I'm not really sure how to phrase this, so apologies if my question is incoherent.