I want to create 10 (at work: 50,000) random data-frames with setting seed for reasons of reproducibility. The seed should be different for each data-frame, also its name should increase from df_01, df_02 ... to df_10. With help of @akrun 's answer I coded a loop like this:
n <- 10
x <- 42
for (i in 1:10) {
set.seed(x)
a <- rnorm(10,.9,.05)
b <- sample(8:200,10,replace=TRUE)
c <- rnorm(10,80,30)
lst <- replicate(i, data.frame(a,b,c), simplify=FALSE)
x <- x+i
}
names(lst) <- paste0('df', 1:10)
Now I have my data-frames, but it seems I can't get he random generation running. All data are similar. When I replace the lst-line with following code at least the seeded randomization works:
print(data.frame(a,b,c))
A crackajack extra would be leading zeros in the dfs-names in order to sort them.
Any help appreciated, thx!
Aucun commentaire:
Enregistrer un commentaire