SpaDES (version 1.1.4)

rndstr: Generate random strings

Description

Generate a vector of random alphanumeric strings each of an arbitrary length.

Usage

rndstr(n, len, characterFirst)

## S3 method for class 'numeric,numeric,logical': rndstr(n, len, characterFirst)

## S3 method for class 'numeric,numeric,missing': rndstr(n, len)

## S3 method for class 'numeric,missing,logical': rndstr(n, characterFirst)

## S3 method for class 'missing,numeric,logical': rndstr(len, characterFirst)

## S3 method for class 'numeric,missing,missing': rndstr(n)

## S3 method for class 'missing,numeric,missing': rndstr(len)

## S3 method for class 'missing,missing,logical': rndstr(characterFirst)

## S3 method for class 'missing,missing,missing': rndstr(n, len, characterFirst)

Arguments

n
Number of strings to generate (default 1). Will attempt to coerce to integer value.
len
Length of strings to generate (default 8). Will attempt to coerce to integer value.
characterFirst
Logical, if TRUE, then a letter will be the first character of the string (useful if being used for object names).

Value

  • Character vector of random strings.

Examples

Run this code
set.seed(11)
rndstr()
rndstr(len = 10)
rndstr(characterFirst = FALSE)
rndstr(n = 5, len = 10)
rndstr(n = 5)
rndstr(n = 5, characterFirst = TRUE)
rndstr(len = 10, characterFirst = TRUE)
rndstr(n = 5, len = 10, characterFirst = TRUE)

Run the code above in your browser using DataLab