r - keep numbers of a vector that recurr more than 3 times -


i have vectors one: c(1, 1, 1, 1, 5, 7, 7, 7, 7, 7). do, keep elements appear more 3 times in vector. in case, obtain following vector c(1, 1, 1, 1, 7, 7, 7, 7, 7) there smart way achieve this? in advance

there number of ways can this, 1 following:

a <- c(1, 1, 1, 1, 5, 7, 7, 7, 7, 7) a[a %in% unique(a)[table(a)>3]] 

with unique(a)[table(a)>3] select elements of vector have more 3 occurrences.

the rest should straightforward


Comments

Popular posts from this blog

java - Ebean enhancement ignores a model -

javascript - Reference error while trying to encapsulate an animation function -

SQL php on different pages to Insert (mysqli) -