I am using R to try to get each user's top 5 favourite songs by which songs they play the most. I currently have code which counts the highest played song but I was wondering how to get the next 4 highest played songs for that user, presuming every user has played at least 5 songs. Would I have to eliminate the highest values from the dataset and run it again or is there an easier way?
write.csv(group_by(mydata,userId) %.%
summarise(favourite=max(playCount)), file="test.csv")
An example of the data looks like this
userId songId playCount
A 568r 85
A 711g 18
C 34n 18
E 454j 65
D 663a 72
B 35d 84
A 34c 72
A 982s 65
E 433f 11
A 565t 7