R/consecutive_id.R

Defines functions consecutive_id

Documented in 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)
}

Try the tidytable package in your browser

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

tidytable documentation built on Sept. 11, 2024, 8:05 p.m.