Here is the code that I am working with. I want to randomly draw numbers and I want to keep doing this until all the numbers 1:18 have been drawn. I do not want to draw the same number twice.
RandomArray <- sample(1:18, 6, replace=F)
RandomArray2 <- sample(1:18,6, replace = F)
RandomArray3 <- sample(1:18,6, replace = F)
RandomArray2 <- ifelse(RandomArray==RandomArray2,
sample(1:18,6,replace=F),RandomArray2)
RandomArray3 <- ifelse(RandomArray2==RandomArray3,
sample(1:18,6,replace=F),RandomArray3)
The ideal output would be
RandomArray [1 2 3 4 5 6] RandomArray2 [7 8 9 10 11 12] RandomArray3 [13 14 15 16 17 18]
I have also tried doing
x <- 1:18
test2 <- sapply(x, function(x)
if (x == RandomArray) x-RandomArray else x)
But that is not right either because I just want to rid of the numbers I have already drawn.
Thank you for your help.
Aucun commentaire:
Enregistrer un commentaire