R/make_id.R

Defines functions make_id

Documented in make_id

#' Creates a unique, numeric ID sequence based on a set of variables
#' 
#' @param ... variables to be used to create unique ID-sequence
#' 
#' @return vector that contains unique numeric id sequence starting with 0 up to K. 
#' 
#' @examples 
#' 
#' library(tidyverse)
#' mtcars %>% mutate( id = make_id(cyl, vs) )
#' 
#' 
#' 
#' 
#' @export
make_id <- function(...) as.numeric(factor(paste(..., sep="_")))
sumtxt/datatools documentation built on Jan. 3, 2021, 1:39 a.m.