Skip to content

Instantly share code, notes, and snippets.

@carlislerainey
Last active September 1, 2015 15:44
Show Gist options
  • Select an option

  • Save carlislerainey/2bc3064839c735d383f0 to your computer and use it in GitHub Desktop.

Select an option

Save carlislerainey/2bc3064839c735d383f0 to your computer and use it in GitHub Desktop.
A short script to randomly pair students.
# some code to randomly pair classmates
# set seed
set.seed(413876)
# a vector of students
students <- c("a", "b", "c", "d")
# create random pairs
n_students <- length(students)
randomized_students <- students[sample.int(n_students)]
pairs <- matrix(randomized_students, ncol = 2)
print(pairs)
# draw a pair at random
pairs[sample.int(nrow(pairs), 1), ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment