CSE361 - Randomly assigning projects to teams

Nick Nikiforakis, Fall 2017

Team names and choices from Piazza

teams <- read.csv("./choices.csv",header=T, stringsAsFactors=F)
teams$c1 <- 0
teams$c2 <- 0
teams$c3 <- 0
teams$assigned <- 0
teams$n_choice_assigned <- 0

for (i in 1:nrow(teams)){
  c_choices <- strsplit(teams$choices[i],",")[[1]]
  teams$c1[i] <- as.numeric(c_choices[1])
  teams$c2[i] <- as.numeric(c_choices[2])
  teams$c3[i] <- as.numeric(c_choices[3])
  }
teams[,c(1,3:5)]
##                                name c1 c2 c3
## 1                          Robertak  2  3  1
## 2                    Raging Mangoes  2  1  3
## 3                       Drop Tables  3  1  2
## 4                               RSA  3  2  1
## 5                         Zero Cool  3  2  1
## 6                        Shellphish  2  3  1
## 7                           BigLink  1  3  2
## 8                        0x5F3759DF  2  1  3
## 9                           Generic  1  2  3
## 10 2b8f31133e9d6246003cd735ef5c8224  2  3  1
## 11                        Where 1=1  1  2  3
## 12                       White Rice  2  3  1
## 13                            Kappa  3  1  2
## 14                   The Salty Dogs  2  1  3
## 15                       2men1shell  2  1  3
## 16                       1337Coders  2  3  1
## 17                          ~$μ@$#~  1  2  3
## 18                       Day Day Up  1  2  3

Sorting the teams by team name

teams.alphab <- teams[order(teams$name),]

Seed is 73 which is the outside temperature in Stonybrook on Wednesday 9/27/2017 at 11:15 AM (time when I am preparing this report) according to Google

set.seed(73)
random_order <- sample(1:nrow(teams),nrow(teams),replace=F)
teams.randomorder <- teams.alphab[random_order,]
teams.randomorder
##                                name choices c1 c2 c3 assigned
## 9                           Generic   1,2,3  1  2  3        0
## 16                       1337Coders   2,3,1  2  3  1        0
## 2                    Raging Mangoes   2,1,3  2  1  3        0
## 12                       White Rice   2,3,1  2  3  1        0
## 17                          ~$μ@$#~   1,2,3  1  2  3        0
## 5                         Zero Cool   3,2,1  3  2  1        0
## 18                       Day Day Up   1,2,3  1  2  3        0
## 1                          Robertak   2,3,1  2  3  1        0
## 6                        Shellphish   2,3,1  2  3  1        0
## 3                       Drop Tables   3,1,2  3  1  2        0
## 7                           BigLink   1,3,2  1  3  2        0
## 4                               RSA   3,2,1  3  2  1        0
## 13                            Kappa   3,1,2  3  1  2        0
## 15                       2men1shell   2,1,3  2  1  3        0
## 14                   The Salty Dogs   2,1,3  2  1  3        0
## 10 2b8f31133e9d6246003cd735ef5c8224   2,3,1  2  3  1        0
## 11                        Where 1=1   1,2,3  1  2  3        0
## 8                        0x5F3759DF   2,1,3  2  1  3        0
##    n_choice_assigned
## 9                  0
## 16                 0
## 2                  0
## 12                 0
## 17                 0
## 5                  0
## 18                 0
## 1                  0
## 6                  0
## 3                  0
## 7                  0
## 4                  0
## 13                 0
## 15                 0
## 14                 0
## 10                 0
## 11                 0
## 8                  0

Parsing order of projects

#Number of teams chosen projects 1-3
project_choices <- c(0,0,0)
project_cap <- 7

#Parse choice order and assign project
for(i in 1:nrow(teams)){
  for (choice_num in 3:5){
    c_choice <- teams.randomorder[i,choice_num]
    
    if (project_choices[c_choice] < project_cap){
      teams.randomorder$assigned[i] <- c_choice
      teams.randomorder$n_choice_assigned[i] <- choice_num - 2
      project_choices[c_choice] <- project_choices[c_choice] + 1
      
      break
    }
  }
}

Project Assignment

print(teams.randomorder[,c(1,6)],row.names=F)
##                              name assigned
##                           Generic        1
##                        1337Coders        2
##                    Raging Mangoes        2
##                        White Rice        2
##                           ~$μ@$#~        1
##                         Zero Cool        3
##                        Day Day Up        1
##                          Robertak        2
##                        Shellphish        2
##                       Drop Tables        3
##                           BigLink        1
##                               RSA        3
##                             Kappa        3
##                        2men1shell        2
##                    The Salty Dogs        2
##  2b8f31133e9d6246003cd735ef5c8224        3
##                         Where 1=1        1
##                        0x5F3759DF        1

Statistics about project assignment

Number of times each project was chosen

barplot(table(teams.randomorder$assigned),xlab="Project",ylab="# times chosen")

Fraction of teams that got their first choice

sum(teams.randomorder$n_choice_assigned == 1) / nrow(teams)
## [1] 0.8888889