duplicates: Determine Duplicates

Description Usage Arguments Value Author(s) Examples

Description

Determine duplicates. duplicates returns a logical vector, duplicatei an integer vector.

Usage

1
2
3
duplicates(x)

duplicatei(x, first = TRUE)

Arguments

x

A vector or data.frame to search for duplicates.

first

Logical, TRUE to return the index also for the first occurrence of values. Otherwise, a 0 is the index for the first occurrence.

Value

duplicates returns a logical vector as duplicated, but with TRUE values also for the first occurrence of duplicated values.
duplicatei returns the index of the first occurrence of each unique value.

Author(s)

Sven E. Templer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#

x <- c(7, 7, 7, 2, 3, 2)
data.frame(
  data = x,
  duplicated = duplicated(x),
  duplicates = duplicates(x),
  duplicatei = duplicatei(x),
  duplicatei0 = duplicatei(x, FALSE))

#

Example output

  data duplicated duplicates duplicatei duplicatei0
1    7      FALSE       TRUE          1           0
2    7       TRUE       TRUE          1           1
3    7       TRUE       TRUE          1           1
4    2      FALSE       TRUE          4           0
5    3      FALSE      FALSE          5           0
6    2       TRUE       TRUE          4           4

miscset documentation built on May 2, 2019, 4:01 a.m.