I am creating a survey. There are 31 questions; I would like each respondent to answer a subset of 3. I would like them to be managed in random order. Participants must not answer the same questions twice
I created a table with a participant index and a column for question indices for the 1st, 2nd and 3rd questions.
Using the code below, index 31 is underrepresented in my example.
I think I am using the sample function incorrectly. I was hoping someone could help me?
SgPassCode <- data.frame(PassCode=rep(0,10000), QIndex1=rep(0,10000), QIndex2=rep(0,10000), QIndex3=rep(0,10000)) set.seed(123) for (n in 1:10000){ temp <- sample(31,3,FALSE) SgPassCode[n,1] <- n SgPassCode[n,-1] <- temp } d <- c(SgPassCode[,2],SgPassCode[,3],SgPassCode[,4]) hist(d)
source share