Conditional/pseudo-random assignment of items to participants

I need to assign a set of texts to a set of participants, according to a combination of rules and probabilities. Some example code:

length_prob <- data.frame("Cat" = c("1A", "1B", "2A", "2B", "3A", "3B", "4A", "4B", "5A", "5B"), "n" = c(0, 6, 37, 58, 123, 81, 67, 44, 48, 36), "Probability" = c(0, 0.012, 0.074, 0.116, 0.246, 0.162, 0.134, 0.088, 0.096, 0.072))

theme_prob <- data.frame("Topic" = c("Death Penalty","Equality","Feminism", "Imagination and Science", "Languages", "Military Service", "Mobile Phones", "Money", "Nature", "Prison", "Television", "University"), "n" = c(51, 17, 70, 68, 16, 5, 20, 62, 1, 42, 57, 91), "Probability" = c(0.102, 0.034, 0.14, 0.136, 0.032, 0.01, 0.04, 0.124, 0.002, 0.084, 0.114, 0.182))

texts_example <- data_frame("Item" = 1:500, "Theme" = sample(c("Death Penalty","Equality","Feminism", "Imagination and Science", "Languages", "Military Service", "Mobile Phones", "Money", "Nature", "Prison", "Television", "University"), 500, replace = TRUE, prob = theme_prob$Probability), "Cat" = sample(c("1A", "1B", "2A", "2B", "3A", "3B", "4A", "4B", "5A", "5B"), 500, replace = TRUE, prob = length_prob$Probability))

participants <- 1:30

I need to assign the items to the participants, such that:

  1. Each text is drawn according the probabilities in the two "_prob" data frames;
  2. Each text is assigned to exactly three participants (this means that, in the example above, there will be 500*3=1500 "assignments");
  3. No participant sees any item more than once
  4. Each participant is assigned the same number of items (in the example, each participant would get be assigned 50 items)

So essentially I'm looking for a process of sampling without replacement, which samples according to two sets of probabilities, proceeds stepwise from one participant to the next, iterates three times, and checks to make sure that the item to be assigned to a judge has not already been assigned during a previous iteration.

Can anyone help?

Peter

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.