lundi 30 mars 2015

Generating a (random) sequence of multiple characters in R



  1. I can create a sequence of single letters using



    LETTERS[seq( from = 1, to = 10 )]
    letters[seq( from = 1, to = 10 )]



  2. I can create a random string of various length, using the random package



    library(random)
    string <- randomStrings(n=10, len=5, digits=TRUE, upperalpha=TRUE,
    loweralpha=TRUE, unique=TRUE, check=TRUE)



Unfortunately, I cannot use the set.seed function for example 2.


Is there a way to create the same (random) combination of (unique) strings everytime one runs a R-file?


My result would look like this (with the same result everytime I run the function):



V1
[1,] "k7QET"
[2,] "CLlWm"
[3,] "yPuwh"
[4,] "JJqEX"
[5,] "38soF"
[6,] "xkozk"
[7,] "uaiOW"
[8,] "tZcrW"
[9,] "8K4Cc"
[10,] "RAhuU"




Aucun commentaire:

Enregistrer un commentaire