generateRunCode: Generate a Unique Run Code

View source: R/generateRunCode.R

generateRunCodeR Documentation

Generate a Unique Run Code

Description

This function generates a unique run code for use in Shiny applications, particularly those running simulations. The code combines a timestamp with a random string to ensure uniqueness for each row or run.

Usage

generateRunCode(time_format = "%Y%m%d%H%M%S", string_length = 5)

Arguments

time_format

A string specifying the format for the timestamp. Default is "%Y%m%d%H%M%S" (year, month, day, hour, minute, second).

string_length

An integer specifying the length of the random string. Default is 5.

Value

A character string containing the unique run code, composed of a timestamp and a random alphanumeric string, separated by an underscore.

Note

This function uses the current system time and a random string to generate the run code. While collisions are extremely unlikely, they are theoretically possible, especially if the function is called multiple times within the same second and with a short string_length.

Examples

generateRunCode()
generateRunCode(time_format = "%Y%m%d", string_length = 8)


mmints documentation built on April 3, 2025, 9:33 p.m.