Show all rows with duplicated values (not just the first or last)

show_duplicated(.tbl, ...)

Arguments

.tbl

Data frame to add transformed variables to

...

Variables used to evaluate row uniqueness

Details

If an entire row is duplicated use "duplicated" to show only one of the duplicated rows. When using a subset of variables to establish uniqueness it may be of interest to show all rows that have (some) duplicate elements

Examples

bind_rows(mtcars, mtcars[c(1,5,7),]) %>% show_duplicated(mpg, cyl)
#> # A tibble: 15 x 12 #> mpg cyl disp hp drat wt qsec vs am gear carb nr_dup #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> #> 1 10.4 8 472 205 2.93 5.25 18.0 0 0 3 4 1 #> 2 10.4 8 460 215 3 5.42 17.8 0 0 3 4 2 #> 3 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 1 #> 4 14.3 8 360 245 3.21 3.57 15.8 0 0 3 4 2 #> 5 15.2 8 276. 180 3.07 3.78 18 0 0 3 3 1 #> 6 15.2 8 304 150 3.15 3.44 17.3 0 0 3 2 2 #> 7 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 1 #> 8 18.7 8 360 175 3.15 3.44 17.0 0 0 3 2 2 #> 9 21 6 160 110 3.9 2.62 16.5 0 1 4 4 1 #> 10 21 6 160 110 3.9 2.88 17.0 0 1 4 4 2 #> 11 21 6 160 110 3.9 2.62 16.5 0 1 4 4 3 #> 12 22.8 4 108 93 3.85 2.32 18.6 1 1 4 1 1 #> 13 22.8 4 141. 95 3.92 3.15 22.9 1 0 4 2 2 #> 14 30.4 4 75.7 52 4.93 1.62 18.5 1 1 4 2 1 #> 15 30.4 4 95.1 113 3.77 1.51 16.9 1 1 5 2 2
bind_rows(mtcars, mtcars[c(1,5,7),]) %>% show_duplicated
#> mpg cyl disp hp drat wt qsec vs am gear carb #> Mazda RX4 21.0 6 160 110 3.90 2.62 16.46 0 1 4 4 #> Hornet Sportabout 18.7 8 360 175 3.15 3.44 17.02 0 0 3 2 #> Duster 360 14.3 8 360 245 3.21 3.57 15.84 0 0 3 4