Summarize and mutate w if condition

Hi, how can I group my table by a certain column and then add the total count and then add another column using mutate function in which added column needs to have a count if a condition is met?

Below is my starting point but not working!!

df1 <- df %>% group_by(ticker,company) %>%
summarize(count = n()) #%>%
#ungroup() %>% mutate(count4 = sum(df$EPS == "4")

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.