Tyu1990 Tyu1990 - 1 month ago 7
R Question

How to create a sum if multiple criteria

I have to create a "sum if" by column with multiple criteria.

I've tried this:

b <- DB.all %>% group_by(Family) %>% summarise(x)


But it doesn't work.

How can I do it?

Answer

Try this:

library(dplyr)
b <- DB.all %>% group_by(Family) %>% summarise(sum(x))