duplicated(x, incomparables = FALSE, ...) ## Default S3 method: duplicated(x, incomparables = FALSE, fromLast = FALSE, nmax = NA, ...) ## S3 method for class 'data.frame': duplicated(x, incomparables = FALSE, fromLast = FALSE, ...) ## S3 method for class 'matrix': duplicated(x, incomparables = FALSE, MARGIN = 1L, fromLast = FALSE, ...) ## S3 method for class 'array': duplicated(x, incomparables = FALSE, MARGIN = 1L, fromLast = FALSE, ...) ## S3 method for class 'POSIXlt': duplicated(x, incomparables = FALSE, ...)anyDuplicated(x, incomparables = FALSE, ...) ## Default S3 method: anyDuplicated(x, incomparables = FALSE, fromLast = FALSE, ...) ## S3 method for class 'array': anyDuplicated(x, incomparables = FALSE, MARGIN = 1L, fromLast = FALSE, ...) ## S3 method for class 'matrix': anyDuplicated(x, incomparables = FALSE, MARGIN = 1L, fromLast = FALSE, ...) ## S3 method for class 'data.frame': anyDuplicated(x, incomparables = FALSE, fromLast = FALSE, ...)
x | a vector, a data frame or an array. Missing values and Infs are allowed. |
incomparables | a vector of values that cannot be compared, each value in x that matches a value in this vector is considered unique. If incomparables=FALSE all values can be compared. |
fromLast | a logical flag, if TRUE, judge the duplicated values from the last to the head. |
nmax | a positive integer or NA. If a positive integer is given then it is considered an error if x contains more than nmax unique values. (This can save memory when working with very long vectors and you are looking for cases with only a few unique values.) |
MARGIN | an integer vector to indicate which subscripts of the matrix or array will be checked for duplicated. 1 indicates rows, 2 indicates columns, c(1,2) indicates rows and columns. |
... | arguments for particular methods. Most methods will call the default method and they will pass a possible nmax argument to it. |
duplicated(c(1,2,1)) duplicated(c(1,2,1), incomparables=TRUE) duplicated(c(1,2,1), fromLast=TRUE) duplicated(matrix(c(1,1,2,2,3,3), nrow=2), MARGIN=1) duplicated(matrix(c(1,1,2,2,3,3), nrow=2), MARGIN=2) duplicated(matrix(c(1,1,2,2,3,3), nrow=2), MARGIN=c(1, 2)) anyDuplicated(c(1,2,3,4), fromLast=TRUE) anyDuplicated(c(1,2,3,3), fromLast=FALSE) anyDuplicated(c(1,2,3,3), fromLast=TRUE)## POSIXlt x <- as.POSIXlt("1970-01-01") duplicated(c(x, x+1, NA, x, x+1, NA))
tryCatch(sum(duplicated(1:1e7, nmax=100)), error=function(e)NA_integer_) tryCatch(sum(duplicated(rep(1,1e7), nmax=100)), error=function(e)NA_integer_)