duplicated2 | R Documentation |
duplicated2()
determines which elements of a vector or data
frame are duplicates, and returns a logical vector indicating which
elements (rows) are duplicates.
duplicated2(x, bothWays=TRUE, ...)
x |
a vector or a data frame or an array or |
bothWays |
if |
... |
further arguments passed down to |
The standard duplicated
function (in package:base
)
only returns TRUE
for the second and following copies of each
duplicated value (second-to-last and earlier when
fromLast=TRUE
). This function returns all duplicated
elements, including the first (last) value.
When bothWays
is FALSE
, duplicated2()
defaults to
a duplicated
call. When bothWays
is TRUE
,
the following call is being executed:
duplicated(x, ...) | duplicated(x, fromLast=TRUE, ...)
For a vector input, a logical vector of the same length as
x
. For a data frame, a logical vector with one element for
each row. For a matrix or array, and when MARGIN = 0
, a
logical array with the same dimensions and dimnames.
For more details see duplicated
.
Liviu Andronic
duplicated
, unique
iris[duplicated(iris), ] # 2nd duplicated value
iris[duplicated(iris, fromLast=TRUE), ] # 1st duplicated value
iris[duplicated2(iris), ] # both duplicated values
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.