I would like to a column to count the number of times a value was used. For example, based on the following code
MyData1=data.frame(Compound = c("c1","c1","c2","c2", "c3"), Damage= c(7,7,8,9,10), Rate = c(8,8,8,8,8))
MyData1 %>% filter(Rate == 8) %>%
group_by(Compound) %>%
dplyr::summarize(Avg_Damage = mean(Damage), Rate = 8) %>%
arrange(Avg_Damage)
I would like an extra column saying how many times c1, c2, and c3 was used, so 2,2,1.
Thank you in advance.