I have a set of data clustered by family, research question is do 2 people in the same family with different characteristic x have the same binary (yes/no) outcome y. In some families, all members are "yes" for y. In other families, some are "yes" and some are "no" for y. I want to get only the families with discordant outcome statuses. I am guessing the code will be some sort of conditional logic statements but can't quite figure it out yet... In the sample data below, for example, I only want to get families 2 and 3. Thank you for your help!
#sample data
df <- as.data.frame(cbind(
famid <- c(1,1,2,2,3,3,3),
individ <- c(1,2,3,4,5,6,7),
y <- c(0,0,0,1,0,0,1)))
colnames(df) <- c("famid", "individ", "y")