I am trying to select all those households where the occupants age group are below 15 and between 30 to 40 from the below data frame. Basically I am looking for households with kids along with their parents
household Members_age
100 75
100 74
100 30
101 20
101 50
101 60
102 35
102 40
102 5
Here only Household 102 satisfy the condition.
I got hint over here subset data based on condition in r but not able to add the 2nd condition to filter i.e. age between 30 - 40
Sample dataset:
library(dplyr)
library(sqldf)
data <- data.frame(household = c(100,100,100,101,101,101,102,102,102),
Members_age = c(75,74,30,20,50,60,35,40,5))