I have random sample of 600 elements from the normal distribtion stored in a vector:
sample_data <- rnorm(600, mean =10, sd = 6)
I am trying to split this vector into 100 random groups of 6 entries each.
Doing this once is a simple proposition with the sample function:
group_1 <- sample(6, sample_data, replace=FALSE)
However, if I use the sample function again there is a chance some of the entries will be re-used because they weren't deleted from the initial data. A possible solution might be to initially store the data in a 100x6 matrix and consider each row as a "random group."
However, I am curious if there is a more efficient method to take consecutive samples from a dataset while ensuring no entry is sampled more than once.
Thanks!
Aucun commentaire:
Enregistrer un commentaire