all_dupes: Find all duplicate rows

View source: R/get_all_dupes.R

all_dupesR Documentation

Find all duplicate rows

Description

Identifies the duplicate values in a column of a data frame (or tibble) and returns a data frame (tibble) with just the duplicate rows.

I actually prefer janitor::get_dupes() but I am including this version for posterity.

Usage

all_dupes(data, x)

Arguments

data

A data frame or tibble

x

The unquoted column name to check for duplicate values

Value

A tibble similar to data

References

https://stat.ethz.ch/pipermail/r-help/2011-October/291383.html

https://stackoverflow.com/questions/7854433/finding-all-duplicate-rows-including-elements-with-smaller-subscripts

Examples

library(dplyr)
library(tibble)
vec <- tibble::tribble(
  ~ID,      ~OS,         ~Date,
  "userA",    "Win",  "12/15/2015",
  "userB",    "OSX",    "1/1/2016",
  "userA",    "Win",  "12/15/2017",
  "userC",  "Win64",    "4/9/2018"
)

all_dupes(data = vec, x = ID)
vec %>%
  all_dupes(ID)

emilelatour/lamisc documentation built on May 10, 2024, 8:38 a.m.