I have a dataframe that looks like this:
data <- data.frame(a=c(1,1,0,0,0,0,1,1,1, 0), b=c(\"x\",\"x\",\"x\",\"x\",\"x\",\"y\",\"y\",\"y\",\"z
We can use
library(dplyr) data %>% group_by(d, b) %>% summarise(e = sum(c[a==1], na.rm = TRUE))
Or
data %>% group_by(d, b) %>% summarise(e = sum((a==1)*c, na.rm = TRUE))