Hello all,

 

I have a question regarding sample() in R. For example, I have a set:

set <- c(2,3,5)

and I want to draw 5 samples from this set, so replacement is true:

m <- sample(set, 5, replace=TRUE) 

However here comes a problem, for example, I will have (2,3,3,2,5), but I
will also  get (3,3,5,5,3) in some cases. This means element 2 has not been
sampled in this case.

The way I want to do is to random sample with replacement, but all elements
have to be sampled.

Any solutions?

 

Thanks!

 

Regards,

Shaofei


	[[alternative HTML version deleted]]

