find_duplicates: Find duplicated values in a vector

View source: R/find_duplicates.R

find_duplicatesR Documentation

Find duplicated values in a vector

Description

Find duplicated values in a vector

Usage

find_duplicates(vector = NULL, na.rm = TRUE, sigfigs = 2, output = "summary")

Arguments

vector

a vector whose elements will be checked for duplicates

na.rm

logical. If na.rm = TRUE, NA values in the vector will be removed before searching for duplicates. If na.rm = FALSE, NA values will be included in the search as potentially duplicated values. By default, na.rm = TRUE.

sigfigs

number of significant digits to round to in the percent column of the summary (default = 2)

output

type of output. If output = "summary", the function's output will be a data.table summarizing duplicated values and their counts. If output = "duplicated_values", the function's output will be a vector of duplicated values. If output = "non_duplicated_values", the function's output will be a vector of non-duplicated values (default = "summary")

Value

the output will be a data.table object (summary), a vector of duplicated values, or a vector non-duplicated values.

Examples

find_duplicates(mtcars$cyl)
find_duplicates(mtcars$cyl, output = "duplicated_values")
find_duplicates(vector = c(mtcars$cyl, 11:20, NA, NA))
find_duplicates(vector = c(mtcars$cyl, 11:20, NA, NA), na.rm = FALSE)
find_duplicates(vector = c(mtcars$cyl, 11:20, NA, NA),
na.rm = FALSE, sigfigs = 4, output = "duplicated_values")

kim documentation built on Oct. 9, 2023, 5:08 p.m.