I have the following data:
x1 x2 x3 x4 34 14 45 53 2 8 18 17 34 14 45 20 19 78 21 48 2 8 18 5
In rows 1 and 3; and
Learned this one the other day. You won't need to re-order the output.
s <- split(dat, do.call(paste, dat[-4])) Reduce(rbind, Filter(function(x) nrow(x) > 1, s)) # x1 x2 x3 x4 # 2 2 8 18 17 # 5 2 8 18 5 # 1 34 14 45 53 # 3 34 14 45 20