I desire to create a random vector of 9776 integer from a specific sequence of numbers, in this case from 1 to 2444, but the unique number of observations has to be equal to 9776.
If I do something like this:
df = data.frame(x = ceiling(runif(9776, 1, 2444)))
I always get length(unique(df$x)) < 2444, e.g.
> length(unique(df$x))
[1] 2398
The same applies for:
df1 = data.frame(x = sample(seq(1, 2444, 1), 9776, replace = TRUE))
> length(unique(df1$x))
[1] 2397
But I actually want length(unique(df$x)) = 2444 while still keeping the random generation.
Any suggestion?
Thanks
Aucun commentaire:
Enregistrer un commentaire