exposeDupes: Expose Duplicates

View source: R/rectangular.R

exposeDupesR Documentation

Expose Duplicates

Description

Sometimes datasets are expected to be tidy but aren't, finding distinct rows of duplicated IDs is easy but finding why they're distinct in many column tables is less straight forward. This functions returns the values that resulted in any duplicated IDs in one of two forms either a named list or a tibble

Usage

exposeDupes(x, grouping_var, listout = TRUE)

Arguments

x

Tibble or Dataframe

grouping_var

Column to look for duplicated values

listout

Flag to return either list or tibble

Details

Named list of two-column tibbles for each value resulting in duplicate IDs

  • Grouping Variable

  • Distinct values

Tibble with the following columns

  • Grouping Variable

  • n * X.grpNdistinct number of distinct values for duplicated ID

  • n * X.values values for that duplicated ID

https://dplyr.tidyverse.org/articles/programming.html

Value

List or Dataframe of results

Examples


  df <- data.frame(name = sample(letters, 20, replace = TRUE),
               month = sample(month.name, 20, replace = TRUE),
            letters = sample(LETTERS[1:10], 20, replace = TRUE),
            nums = floor(runif(20, 1, 15)))
  dplyr::count(df, name)
  exposeDupes(df, name)
  exposeDupes(df, name, listout = FALSE)
  

TheZetner/utilitarian documentation built on Aug. 13, 2022, 12:31 p.m.