SHARE
TWEET

Untitled

a guest Aug 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. getRandSamples <- function(seed = NA){
  2.   if (!is.na(seed)){
  3.     set.seed(seed) #incase you need repeatable data generation.
  4.     #but remember to set a different seed for each person if you want them to get different items at each time point.
  5.   }
  6.  
  7.   True_New <- sample(1:20,20,replace = F) #items that are true + new
  8.   True_Rep <- sample(21:40,20,replace = F) #items that are true + repeated
  9.   False_New <- sample(41:60,20,replace = F) #items that are false + new
  10.   False_Rep <-sample(61:80,20,replace = F) # items that are false + repeated
  11.  
  12.   items <- list(True_New, True_Rep, False_New, False_Rep)
  13.  
  14.   t1 <- sapply(items, function(x) x[1:5]) #items to give at time 1
  15.   t2 <- sapply(items, function(x) x[6:10]) #items to give at time 2
  16.   t3 <- sapply(items, function(x) x[11:15]) #items to give at time 3
  17.   t4 <- sapply(items, function(x) x[16:20]) #items to give at time 4
  18.  
  19.   #return dataframe with time and items for each time point
  20.   return(data.frame(time = sort(rep(0:3,20)),
  21.                     item = c(t1,t2,t3,t4)))
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top