There is a data frame need to subset based on households, Ethnic, PERSNUM columns.
I have to get all households have have member of a ethnic (e.g here ethnic 11).
There five columns NUMBER, Number_2, Number_3, PERSNUM, and ETHNIC Three of Number columns are households have to group
df <- data.frame(
Village = c(rep("1", "30")),
Number = c(33, 33, 33, 33, 33, 33, 33, 1, 1, 30, 30, 30, 30, 30, 30, 30,
31, 31, 31, 31, 36, 36, 36, 36, 62, 62, 62, 62, 69, 69),
Number_1 = c(183, 183, 183, 183, 183, 183, 183, 151, 151, 255, 255, 255, 255, 255, 255,
255, 31, 31, 31, 31, 111, 111, 111, 111, 287, 287, 287,287, 219, 219),
Number_3 = c(137, 137, 137, 137, 137, 137, 137, 113, 113, 191, 191, 191, 191, 191, 191,
191, 23, 23, 23, 23, 83, 83, 83, 83, 215, 215, 215, 215, 164, 164),
PERSNUM = c(1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 1, 2, 3, 4, 5, 6,
1, 2, 3, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2),
ETHNIC = c(33, 33, 33, 33, 33, 33, 33, 1, 1, 1, 1, 1, 1, 0, 11,
11, 11, 11, 11, 11, 0, 0, 11, 11, 11, 11, 11, 11, 11, 11))