Hello Everyone,
Can some help with how to generate a unique 6 digit URN in R,as I don't know how to do this please. Below are the rule for the URN
- It needs to be alphanumeric,start with letter and maybe end with letter (e.g AA34YB)
- Use only upper case alphabets
- Do not use the alphabets O or I (this is the alphabet after H and before J)
- Use only digits from 1- 9. Exclude 0
- First two digit should be letter,then followed by 2 digit number and end with 2 digit letter,e.g "AA22DD","EE34TY","ER67YU"
- All records must contain number as shown in rule 5
- IT MUST BE 6 DIGIT PLEASE
I would love to generate upto 4 million unique records please.Any R code suggestion is highly welcome.I am not an expert in R,actually new to R
I would love to generate upto 4 million unique records please.Any R code suggestion is highly welcome
I have tried following but it does not produce the output I need
tt <- c(65:72,74:78,80:90)
replicate(10,rawToChar(as.raw(c(sample(tt, 1), sample(c(tt,49:57), 5, replace = TRUE)))))
replicate(10, paste0(c(sample(LETTERS[!LETTERS %in% c("O", "I")], 1),
sample(c(LETTERS[!LETTERS %in% c("O", "I")], 1:9), 4),
sample(LETTERS[!LETTERS %in% c("O", "I")], 1)), collapse = ''))
myletters <- LETTERS[!LETTERS %in% c("O", "I")]
mydigits <- 1:9
get_key <- function(l, d){
paste0(sample(l, 1), sample(c(l, d), 2, replace = TRUE), collapse = "")
}
replicate(100, get_key(myletters, mydigits))