Dplyr solution: calculate the length of unique cities for each household and save only those with a length> 1
library(dplyr)
df <- data.frame(city=c("Paris","Paris","Nice","Limoge","Limoge","Toulouse","Paris"),
household =c(rep("A",3),rep("B",2),rep("C",2)))
new_df <- df %>% group_by(household) %>%
filter(n_distinct(city) > 1)
Source: local data frame [5 x 2]
Groups: household
city household
1 Paris A
2 Paris A
3 Nice A
4 Toulouse C
5 Paris C
: @shadow @davidarenburg