Description Usage Arguments Value See Also Examples
rray_duplicate_any()
: returns a logical with the same shape and type
as x
except over the axes
, which will be reduced to length 1. This
function detects the presence of any duplicated values along the axes
.
rray_duplicate_detect()
: returns a logical with the same shape and
type as x
describing if that element of x
is duplicated elsewhere.
rray_duplicate_id()
: returns an integer with the same shape and
type as x
giving the location of the first occurrence of the value.
1 2 3 4 5 | rray_duplicate_any(x, axes = NULL)
rray_duplicate_detect(x, axes = NULL)
rray_duplicate_id(x, axes = NULL)
|
x |
A vector, matrix, array, or rray. |
axes |
An integer vector. The default of |
See the description for return value details.
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.