Reputation: 1134
df2<- df %>%
group_by(ID)%>%
summarise(Count= sum(df$value=="Y"))
However when I do this I get Count column as NA
df2<- df %>%
group_by(ID)%>%
summarise(Count= sum(value=="Y"))
Same when I do this. I would like to get the numbers to show up.
Upvotes: 0
Views: 54
Reputation: 5167
if value is ever NA it will spoil your sum so
df2<- df %>%
group_by(ID)%>%
summarise(Count= sum(value=="Y",na.rm=TRUE))
Upvotes: 1