Last active
September 1, 2015 15:44
-
-
Save carlislerainey/2bc3064839c735d383f0 to your computer and use it in GitHub Desktop.
A short script to randomly pair students.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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