Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getRandSamples <- function(seed = NA){
- if (!is.na(seed)){
- set.seed(seed) #incase you need repeatable data generation.
- #but remember to set a different seed for each person if you want them to get different items at each time point.
- }
- True_New <- sample(1:20,20,replace = F) #items that are true + new
- True_Rep <- sample(21:40,20,replace = F) #items that are true + repeated
- False_New <- sample(41:60,20,replace = F) #items that are false + new
- False_Rep <-sample(61:80,20,replace = F) # items that are false + repeated
- items <- list(True_New, True_Rep, False_New, False_Rep)
- t1 <- sapply(items, function(x) x[1:5]) #items to give at time 1
- t2 <- sapply(items, function(x) x[6:10]) #items to give at time 2
- t3 <- sapply(items, function(x) x[11:15]) #items to give at time 3
- t4 <- sapply(items, function(x) x[16:20]) #items to give at time 4
- #return dataframe with time and items for each time point
- return(data.frame(time = sort(rep(0:3,20)),
- item = c(t1,t2,t3,t4)))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement