Reputation: 971
I have a set of data which I would like a subset of. I would like the subset defined as those rows with a value for variable X which appears more than once. Variable X is a string.
So, for example, if x consisted of ('help','me,'me','with','this','this'), it would return the rows with the x values ('me','me','this,'this').
Thank you so much for your help!
Upvotes: 6
Views: 1334
Reputation: 176638
Something like this should work:
x <- c('help','me','me','with','this','this')
x[duplicated(x, fromLast=TRUE) | duplicated(x)]
Upvotes: 14