Description Usage Arguments Details Value See Also Examples
Get the unique rows in a dataset, or identify the duplicates.
| 1 2 3 4 5 6 | ## S3 method for class 'dataset'
anyDuplicated(x, incomparables = FALSE, ...)
## S3 method for class 'dataset'
duplicated(x, incomparables = FALSE, ...)
## S3 method for class 'dataset'
unique(x, incomparables = FALSE, ...)
 | 
| x | a dataset object. | 
| incomparables | ignored. | 
| ... | ignored. | 
These functions convert their argument x to a dataset and identify
the unique rows. They do so by first transforming the columns of x
to identity proxies via the idproxy function.
Note that idproxy is not defined for list variables, so
consequently anyDuplicated, duplicated, and unique
will raise an error when x contains a list column.
For anyDupicated, the index of the first duplicated row, or 0
if all are unique.
For duplicated, a logical vector with length equal to the number
of rows in x and entries indicating whether or not each row
is a duplicate of an earlier row.
For unique, a dataset with rows giving the unique rows in x.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # identify duplicated elements
x <- dataset(one = c(  1,   1,   2,   2,   1,   1),
             two = c("a", "b", "a", "b", "a", "b"))
anyDuplicated(x)
duplicated(x)
# extract unique rows
unique(x)
# call the method explicitly to convert the argument
is.dataset(unique.dataset(mtcars))
# base-R 'unique' fails with R version < 3.5; 'unique.dataset' succeeds
x <- data.frame(first = c(.15, .10 + .05), second = c(1, 1))
unique(x$first)
unique(x)
unique.dataset(x)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.