Help with data frame please

Hello everyone! I am conducting research on songs and I need to get audio features on songs from Spotify. I am using the following guide. Spotify’s “This Is” playlists: the ultimate song analysis for 50 mainstream artists | by James Le | Towards Data Science . However, I am having an issue with the data.frame.

I am very new to coding and would appreciate any help!

Thanks!

1 Like

Hi,

You might check to see if there is a conflict between the contents of the your csv file and the parameters you pass to read.csv(). For instance, if I squint really hard I think I see commas as column separators in playListURI, but you explicitly tell read.csv() to use semi-colons. Could that be the source of your trouble?

Ben

Well, I changed "sep = ","" to"sep = ","" and I got the same error but instead of 0 and 2, it was 99 , 98.

Well, that's progress!

So, you are trying to column-bind objects of different lengths. Have you tried simply creating each of the objects outside of the column-binding step? Maybe like this?

n <- nrow(playlistURI)
PlayListID <- playlistURI[,2]
Musician <- playlistURI[,1]
PlayListSong <- sapply(seq_len(n), function(i) getPlaylistSongs("Spotify", playlistURI[,2], token = spotifyToken)
length(PlayListID)
length(Musician)
length(PlayListSong)

Perhaps that will provide a clue?

Ben

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.