How to get a subset of a DataFrame that only has elements that appear in a set more than once in R

I have a dataset that I would like to get a subset of. I would like the subset to be defined as strings with a value for the variable X that appears more than once. The variable X is a string.

So, for example, if x consisted of ("help", "me", "me", "with", 'this', 'this'), it returned rows with the values ​​x ('me', 'me', " this, 'this').

Thank you so much for your help!

+6
source share
1 answer

Something like this should work:

x <- c('help','me','me','with','this','this') x[duplicated(x, fromLast=TRUE) | duplicated(x)] 
+14
source

Source: https://habr.com/ru/post/888970/


All Articles