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
Post a Comment