unik mengembalikan vektor, bingkai data, atau larik seperti x tetapi dengan elemen/baris duplikat dihapus.
unique(x, incomparables = FALSE, …)<p></p><p># S3 method for default
unique(x, incomparables = FALSE, fromLast = FALSE,
nmax = NA, …)</p><p># S3 method for matrix
unique(x, incomparables = FALSE, MARGIN = 1,
fromLast = FALSE, …)</p><p># S3 method for array
unique(x, incomparables = FALSE, MARGIN = 1,
fromLast = FALSE, …)</p>
| Parameter | Deskripsi |
|---|---|
x |
a vector or a data frame or an array or NULL. |
incomparables |
a vector of values that cannot be compared. FALSE is a special value, meaning that all values can be compared, and may be the only value accepted for methods other than the default. It will be coerced internally to the same type as x. |
fromLast |
logical indicating if duplication should be considered from the last, i.e., the last (or rightmost) of identical elements will be kept. This only matters for names or dimnames. |
nmax |
the maximum number of unique items expected (greater than one). See duplicated. |
… |
arguments for particular methods. |
MARGIN |
the array margin to be held fixed: a single integer. |
# NOT RUN {
x <- c(3:5, 11:8, 8 + 0:5)
(ux <- unique(x))
(u2 <- unique(x, fromLast = TRUE)) # different order
stopifnot(identical(sort(ux), sort(u2)))
length(unique(sample(100, 100, replace = TRUE)))
## approximately 100(1 - 1/e) = 63.21
unique(iris)
# }