# example df = expand.grid(A = c('a', 'b', 'c', 'd'), B = c('a', 'b', 'c', 'd')) # remove redundant combinations df[!duplicated(data.frame(t(apply(df,1,sort)))),]