R/invert_id.R

Defines functions invert_id

Documented in invert_id

#' Invert identifier
#'
#' Invert the identifier (generated by [generate_id()] for one or more constructs.
#' This means that the identifier prefix is stripped and the last part is
#' converted back from base 30 to base 10.
#'
#' @param x The identifier(s) as a character vector.
#'
#' @return The identifier(s) as a numeric vector.
#' @export
#'
#' @examples
#' invert_id(generate_id('example'));
invert_id <- function(x) {
  datetimeBit <- gsub("^.*_([^_]+)$",
                      "\\1",
                      x);
  return(base30toNumeric(datetimeBit));
}

Try the psyverse package in your browser

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

psyverse documentation built on March 7, 2023, 8:31 p.m.