What I'm trying to do is use the sample function in R to split up a sequence of numbers into several equal parts for later use, but I'm having a hard time not getting repeated digits even when I indicate that I don't want replacement values.
trials <- seq(1,21,1)
set.seed(5)
p1.trials <- sample(trials, 7, replace=F)
p1.trials
This yields the vector : 5, 14, 18, 6, 2, 12, 8
trials <- trials[-p1.trials]
p2.trials <- sample(trials, 7, replace=F)
p2.trials
This yields the vector: 19, 20 , 3 , 7 ,9 , 4 ,16
p3.trials <- trials[-p2.trials]
p3.trials
This yields the vector: 1 , 3 , 9,10 ,13 ,16 ,17, 19, 20, 21
Can anybody help me figure out why (a) I'm getting repeated values (e.g., "3" is in the p2.trials and p3.trials) and (b) why the p3.trials subsetting produces 10 numbers instead of 7?