Create a Vector of Random Character Strings with Certain Length
Here, in this method to create a vector of random character strings with a certain length, the user needs to call the randomStrings() function from the random package passed with the required parameters accordingly to get the vector of random character strings with specified length in the R programming language.
Example:
In this example, we are calling the randomStrings() function with the as.vector() function passed with the n=10 which is the length of the vector generated, and len=5 which here is the length of the strings in the vectors further this will be generating the vector of random character strings of size 10 and the length of the string 5 in the R programming language.
R
RandomStringVector = as.vector ( randomStrings (n = 10, len = 5)) RandomStringVector |
Output:
[1] “D6T5f” “3lQBT” “ljrUM” “YzRuu” “JoJhH” “fsCCw” “291oM” “5wvjn” “ensjF” “Ijno1”
Random Package in R
In this article, we will discuss the random package including its use with working examples in the R programming language.