R/consecutive_id.R

Defines functions consecutive_id. consecutive_id

Documented in consecutive_id consecutive_id.

#' Generate a unique id for consecutive values
#'
#' @description
#' Generate a unique id for runs of consecutive values
#'
#' @param ... Vectors of values
#'
#' @export
#'
#' @examples
#' x <- c(1, 1, 2, 2, 1, 1)
#' consecutive_id(x)
consecutive_id <- function(...) {
  check_dots_unnamed()

  data <- data_frame(..., .name_repair = "minimal")

  rleidv(data)
}

#' @export
#' @keywords internal
#' @inherit consecutive_id
consecutive_id. <- function(...) {
  deprecate_dot_fun()
  consecutive_id(...)
}

Try the tidytable package in your browser

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

tidytable documentation built on Oct. 5, 2023, 5:07 p.m.