You can use count from the plyr package to count the occurrence of an element and remove everyone that happens more than once.
library(plyr) l = c(1,2,3,3,4,5,6,6,7) count_l = count(l) x freq 1 1 1 2 2 1 3 3 2 4 4 1 5 5 1 6 6 2 7 7 1 l[!l %in% with(count_l, x[freq > 1])] [1] 1 2 4 5 7
Pay attention to ! which means NOT . You, of course, put this in the oneliner:
l[!l %in% with(count(l), x[freq > 1])]
source share