Learn R Programming

scrutiny (version 1.0.0)

duplicate_count: Count duplicate values

Description

duplicate_count() returns a frequency table of the values in a vector or data frame. For a data frame, it pools the values of all columns and records which columns each value appears in.

This is a blunt tool for initial checks. If many values have few characters each, duplicates occur by chance and mean little.

Call audit() on the output for summary statistics.

Usage

duplicate_count(x, ignore = NULL, locations_type = c("character", "list"))

Value

A tibble with these columns, or only the first two if x is not named:

  • value: the distinct values of x.

  • frequency: how often each occurs, in descending order.

  • locations: the names of the columns of x in which value appears.

  • locations_n: the number of such columns.

The tibble has the class scrutiny_dup_count, which is recognized by audit().

Arguments

x

Vector, matrix, or data frame. Missing values are not counted, nor are blank strings, "NA", and "NaN", which count as missing.

ignore

Optionally, a vector of values not to count.

locations_type

String. "character" (the default) pastes the column names in locations into one string; "list" keeps them as a vector per value, which is better for programming.

Summaries with <code>audit()</code>

audit() on duplicate_count() output returns summary statistics for frequency and locations_n (or frequency alone if x is not named).

See Also

  • duplicate_count_colpair() for duplicates between pairs of columns.

  • duplicate_tally() for counts next to each value.

  • janitor::get_dupes() for duplicate rows.

Examples

Run this code
iris |>
  duplicate_count()

iris |>
  duplicate_count() |>
  audit()

# Ignore some values:
iris |>
  duplicate_count(ignore = c("setosa", "versicolor", "virginica"))

Run the code above in your browser using DataLab