The question is: How many households live in area 2, earn more than 20k, and have purchased more than 30 units of pasta over the whole time period?
I tried
pasta %>%
filter(AREA=="2") %>% group_by(HHID) %>%
summarise(buy2= sum(PASTA), INCOME) %>%
summarise(income2 = INCOME > "20000" && buy2 > "30")
# run and show
`summarise()` has grouped output by 'HHID'. You can override using the `.groups` argument.
A tibble: 403 x 2
HHID income2
<int> <lgl>
1 10 TRUE
2 16 TRUE
3 17 FALSE
4 29 TRUE
5 30 FALSE
6 31 FALSE
7 36 TRUE
8 42 FALSE
9 47 TRUE
10 60 TRUE
# … with 393 more rows
How can I count the 'TRUE'?