I want to generate random lines as follows: ABCDE1234E , that is, each line contains 5 characters, 4 numbers, then 1 Char.
I figured out a way to create this using the following code.
library(random) string_5 <- as.vector(randomStrings(n=5000, len=5, digits=FALSE, upperalpha=TRUE, loweralpha=FALSE, unique=TRUE, check=TRUE)) number_4 <- as.vector(randomNumbers(n=5000, min=1111, max=9999, col=5, base=10, check=TRUE)) string_1 <- as.vector(randomStrings(n=5000, len=1, digits=FALSE, upperalpha=TRUE, loweralpha=FALSE, unique=FALSE, check=TRUE)) PAN.Number <- paste(string_5,number_4,string_1,sep = "")
But these functions take a lot of time, and the random library requires a network connection.
> system.time(string_5 <- as.vector(randomStrings(n=5000, len=5, digits=FALSE, upperalpha=TRUE, + loweralpha=FALSE, unique=TRUE, check=TRUE))) user system elapsed 0.07 0.00 3.18
Is there any method that I could try to shorten the execution time? I also tried using sample() , but I could not figure it out.
random r
Nikhil Kumar
source share