答案 0 :(得分:2)
有许多解决此问题的方法。如果您想以tidy
的方式解决它,我建议这样做:
library(dplyr)
library(tibble)
df = tribble(~name, ~value,
"ananas", 42,
"apple", 4,
"apple", 69,
"bike", 70)
df %>%
add_count(name) %>%
filter(n!=1) %>%
select(-n)
# A tibble: 2 x 2
name value
<chr> <dbl>
1 apple 4
2 apple 69