R/creatingContestants.R

Defines functions createContestants

Documented in createContestants

#' Creating the Initial Pairings
#' 
#' @description 
#' This function takes an integer to generate a pool of contestants pairings based on the input size.
#'
#' @details  
#' Using a sample function this randomizes the assignment of females to males. Technically this is not necessary but it is more fun.
#' 
#' @param contestants The number of pairs to create and must be an integer
#'
#' @return 
#' A tibble of with nrow == contestants with names female and male. Both columns are character with male being in numerical order of m\\d and female to be randomized.
#'
#' @export 
#' 
#' @examples
#' createContestants(8)
#' 
#' require(purrr)
#' map(5:10, createContestants) #creates a list of dataframes
#' \dontrun{
#' createContestants("a")
#' createContestants(0)
#' createContestants(TRUE) 
#' createContestants(6.1)
#' }

#create the initial pairings of couples
#future want - make the algo pull from a list of names 
createContestants = function(contestants){

    validateCreatingContestants(contestants)
    #make a vector 1:number of contestants
    contestantNums = seq_along(1:contestants)

    #combine the contestant vector with F to generate F1... Fn
    female = sprintf("f%s", contestantNums)

    #randomly assign the female contestants to the male counterparts
    tibble(
        female = sample(female, size = contestants, replace = FALSE),
        male = sprintf("m%s", contestantNums)
        )

}
NotThatKindODr/Are-You-The-One-Sim documentation built on Dec. 17, 2021, 12:51 p.m.