hi guys,

i have a tibble, and i want count number of observation duplicated in column(frequently observation) , how can do it?

```
my_tib <- tibble(x = sample(100, rep = TRUE), y = sample(100, rep = TRUE))
```

hi guys,

i have a tibble, and i want count number of observation duplicated in column(frequently observation) , how can do it?

```
my_tib <- tibble(x = sample(100, rep = TRUE), y = sample(100, rep = TRUE))
```

There are no duplicated observations in your dataframe (i.e. x and y values duplicated between rows) but this is an example of how to find duplicated `x`

values in your sample dataframe.

```
library(tidyverse)
my_tib <- tibble(x = sample(100, rep = TRUE), y = sample(100, rep = TRUE))
my_tib %>%
group_by(x) %>%
filter(n() > 1) %>%
distinct(x, .keep_all = TRUE)
#> # A tibble: 22 x 2
#> # Groups: x [22]
#> x y
#> <int> <int>
#> 1 43 97
#> 2 80 98
#> 3 77 70
#> 4 12 100
#> 5 57 33
#> 6 72 72
#> 7 47 76
#> 8 100 88
#> 9 17 100
#> 10 26 34
#> # … with 12 more rows
```

If this doesn't solve your problem, please elaborate more in your question and reproducible example, you are not making very clear your request.

@andresrcs

Suppose I have a 100-row tibble that has two columns A, B. In the column A, there are 10 numbers that are repeated, for example, the number 1 is repeated for 5 times in rows and ... Now I want to count the number of repetitions of each of these 10 numbers.

Like this?

```
library(tidyverse)
my_tib <- tibble(A = sample(100, rep = TRUE), B = sample(100, rep = TRUE))
my_tib %>%
count(A) %>%
filter(n > 1)
#> # A tibble: 26 x 2
#> A n
#> <int> <int>
#> 1 1 2
#> 2 2 2
#> 3 5 3
#> 4 11 2
#> 5 14 2
#> 6 24 2
#> 7 25 2
#> 8 37 2
#> 9 40 2
#> 10 43 2
#> # … with 16 more rows
```

^{Created on 2019-07-27 by the reprex package (v0.3.0.9000)}

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.