conditional var count with different classes in R -
i have data frame looks that:
class id rank aa win b aa win b ab win c bb win d ab win e bb win e aa win
how can efficiently count how wins
per id
have condition of class lower e
(not inclusive)?
a dplyr solution:
library(dplyr) df%>% group_by(id) %>% filter(class !="e") %>%summarize(n())
Comments
Post a Comment