I am trying to run a simulation where after every 10 draws, everything drawn will be replaced. However, it is running for 100 samples. I am trying to have all 100 draws done at once, under different seeds, but I am trying to regulate the seeds. I do not know how to have the replace occur every 10 draws, though. Here is some code:
i = 0
while 1=1 :{
x <- sample(1:100, 100, replace = FALSE) # HERE IS WHERE I NEED THE REPLACE TO BE TRUE EVERY 10
# my thought is to put an if statement of some sort that resets the sample, but I am not sure how
# to accomplish such
if(x >= 1000):
print("Seed ", i, " exceeded expectations")
i = i 1
}
I realize the above code does not have a break, this is just some starter code for as far as I have figured out. Any insight is appreciated
CodePudding user response:
is that what you are thinking of?
lapply(1:100,function(x) {
set.seed(x)
sample(1:100,10,replace = F)
})