I'm migrating from plyr to dplyr. I replaced
ddply(data, c("sampleno"), function(s) s[which.max(s$voice_score),])
with
data %>% group_by(sampleno) %>% top_n(1, voice_score)
but ran into a problem because top_n
includes multiple entries in case of a tie, which is not what I want. It doesn't matter how it breaks symmetry so long as I only get one result -- how should I do this?