I have a dataset where i need to work on repeating ID'S , but some IDS are repeating more than two times which i want to trace.
- how can i identify them with out removing
- how can i trace them
I have a dataset where i need to work on repeating ID'S , but some IDS are repeating more than two times which i want to trace.
Here's a dplyr
solution.
library(dplyr, warn.conflicts = FALSE)
data <- tibble(
id = c(1, 1, 2, 3, 4, 4, 4, 5, 6, 7),
col = letters[1:10]
)
data
#> # A tibble: 10 x 2
#> id col
#> <dbl> <chr>
#> 1 1 a
#> 2 1 b
#> 3 2 c
#> 4 3 d
#> 5 4 e
#> 6 4 f
#> 7 4 g
#> 8 5 h
#> 9 6 i
#> 10 7 j
data %>%
group_by(id) %>%
filter(n() > 2)
#> # A tibble: 3 x 2
#> # Groups: id [1]
#> id col
#> <dbl> <chr>
#> 1 4 e
#> 2 4 f
#> 3 4 g
Created on 2020-09-10 by the reprex package (v0.3.0)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.