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

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -