R/util_duplicated_inclding_first.R

Defines functions util_duplicated_inclding_first

#' Get duplicates including first instance
#'
#' @param x object to pass do [base::duplicated()] as `x`
#' @param ... passed to [base::duplicated()] as `...`
#'
#' @returns see [base::duplicated()]
#' @noRd
#' @seealso [`StackOverflow`](https://stackoverflow.com/a/7854620)
#' @author [`Joshua Ulrich`](https://stackoverflow.com/users/271616/joshua-ulrich)
util_duplicated_inclding_first <- function(x, ...) {
  if (is.vector(x) || is.data.frame(x)) {
    return(duplicated(x, ...) | duplicated(x, fromLast=TRUE, ...))
  } else {
    util_error("Object of unsupported class %s passed",
               sQuote(paste(class(x), collapse = ", ")))
  }
}

Try the dataquieR package in your browser

Any scripts or data that you put into this service are public.

dataquieR documentation built on Jan. 8, 2026, 5:08 p.m.