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

rndstr(n, len, characterFirst)

# S4 method for numeric,numeric,logical
rndstr(n, len, characterFirst)

# S4 method for numeric,numeric,missing
rndstr(n, len)

# S4 method for numeric,missing,logical
rndstr(n, characterFirst)

# S4 method for missing,numeric,logical
rndstr(len, characterFirst)

# S4 method for numeric,missing,missing
rndstr(n)

# S4 method for missing,numeric,missing
rndstr(len)

# S4 method for missing,missing,logical
rndstr(characterFirst)

# S4 method for 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.

Author

Alex Chubaty and Eliot McIntire

Examples

set.seed(11)
rndstr()
#> [1] "HTofMAXR"
rndstr(len = 10)
#> [1] "lklZtCtkys"
rndstr(characterFirst = FALSE)
#> [1] "GCIxMuDK"
rndstr(n = 5, len = 10)
#> [1] "M5J2yGhbsx" "c9fpax8XD6" "hToX6PIg4r" "rAjZqgLlbJ" "CNCwMrqrBZ"
rndstr(n = 5)
#> [1] "uLB5dkBg" "kuPWfZKO" "c3OG6r2r" "QvkZbMwg" "hhPG2ZnA"
rndstr(n = 5, characterFirst = TRUE)
#> [1] "gIg7ECJc" "bLdEaxL9" "hib6YIC3" "Ms3nvISn" "fV8i0Lgz"
rndstr(len = 10, characterFirst = TRUE)
#> [1] "RN3VaqESAL"
rndstr(n = 5, len = 10, characterFirst = TRUE)
#> [1] "rvomtUDlEQ" "PWN2z2MpUY" "CFariE59hK" "JF4c5WI7f4" "o7RfszlTs9"