Reputation: 1
I have a dataset called songs.merge
with variables
songID
, songName
, year
, artist
, score1
, score2
and score.diff
I want to aggregate(sum) the score.diff according to the artist, count the number of songs per artist, and then remove any artists with fewer than 4 songs in the dataframe.
I am trying to use dplyr in r but it is not working. How should I proceed?
songs.merge %>%
group_by(artist) %>%
summarise_at(vars(diff),funs(sum(.,na.rm=TRUE)),
vars(songID), funs(count()))
Upvotes: 0
Views: 222
Reputation:
suggestion:
songs.merge %>%
group_by(artist) %>%
summarise(sum_diff = sum(score.diff, na.rm = TRUE),
song_count = n()) %>%
filter(song_count > 3)
Upvotes: 1