rray_duplicate: Find duplicated values in an array

Description Usage Arguments Value See Also Examples

Description

Usage

1
2
3
4
5

Arguments

x

A vector, matrix, array, or rray.

axes

An integer vector. The default of NULL looks for duplicates over all axes.

Value

See the description for return value details.

See Also

rray_unique() for functions that work with the dual of duplicated values: unique values.

vctrs::vec_duplicate_any() for functions that detect duplicates among any type of vector object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
x <- rray(c(1, 1, 2, 2), c(2, 2))
x <- rray_set_row_names(x, c("r1", "r2"))
x <- rray_set_col_names(x, c("c1", "c2"))

# Are there duplicates along the rows?
rray_duplicate_any(x, 1L)

# Are there duplicates along the columns?
rray_duplicate_any(x, 2L)

# Create a 3d version of x
# where the columns are not unique
y <- rray_expand(x, 1)

# Along the rows, all the values are unique...
rray_duplicate_any(y, 1L)

# ...but along the columns there are duplicates
rray_duplicate_any(y, 2L)

# ---------------------------------------------------------------------------

z <- rray(c(1, 1, 2, 3, 1, 4, 5, 6), c(2, 2, 2))

# rray_duplicate_detect() looks for any
# duplicates along the axes of interest
# and returns `TRUE` wherever a duplicate is found
# (including the first location)
rray_duplicate_detect(z, 1)

# Positions 1 and 5 are the same!
rray_duplicate_detect(z, 3)

# ---------------------------------------------------------------------------

# rray_duplicate_id() returns the location
# of the first occurance along each axis.
# Compare to rray_duplicate_detect()!
rray_duplicate_detect(z, 1)
rray_duplicate_id(z, 1)

rray documentation built on July 23, 2019, 5:04 p.m.