Skip to main content

Posts

Showing posts from April, 2022

A lunch roulette algorithm in R

The purpose of the algorithm described here is to randomly create pairs from a list of people to go out for lunch. As an input, this algorithm needs a list of people created as shown below and saved to a file called people.csv , in UTF-8 format. j ill.valentine@capcom.com,Jill Valentine,1 j ames.bond@mi6.gov.uk,007,1 t ony.stark@marvel.com,Tony Stark,2 d avid@konami.com,Solid Snake,1 h annibal.lecter@jhu.edu,Hannibal Lecter,0 l ara.croft@core-design.com,Lara Croft,2 d aenerys.targaryen@hbo.com,Daenerys Targaryen,1 w alter.white@caltech.edu,Heisenberg,1 Each line in this file should contain an email address, a name, and a code that should be set to 0, 1 or 2. Code 0 means ignored, so only people with codes 1 or 2 are considered when creating new pairs. In case of an odd number of people with codes 1 or 2, 1 randomly selected person with code 2 is discarded. In order to not have to worry about odd numbers, it is best to always have at least 1 person with code 2. Also important to k