R/ExampleFunction.R

Defines functions WhoIsTheCoolest

Documented in WhoIsTheCoolest

#' @title Function to determine coolest person
#' @name WhoIsTheCoolest
#' @param people hsdlnjkgbdj
#' @param \dots Arguments to be passed through
#' @rdname WhoIsTheCoolest
#' @description This function uses the \code{\link{runif}} to assign a coolness
#'  Index to each person from \code{people} argument and selects the maximum value
#'  of the coolness index as the coolest person.
#' @author Gareth Burns
#' @export


WhoIsTheCoolest <-
  function(people =  c(
    "Aisling",
    "Alecia",
    "Andrew",
    "Antonia",
    "Fiona",
    "Gerard",
    "Gareth",
    "Jack",
    "Jamie",
    "Kara",
    "Rebecca",
    "Sam",
    "Sheila",
    "Sofia"
  ),
  ...) {
    # Basic Validation
    stopifnot(length(people) > 1L, is.character(people))

    coolnessIndex <- sapply(people, function(person) {
      runif(1L)
    })

    coolestPerson <- names(coolnessIndex[which.max(coolnessIndex)])

    if (coolestPerson == "Andrew") {
      print(sprintf("%s is the coolest!", coolestPerson))

    } else {
      print(sprintf("%s is the coolest! and it's not Andrew", coolestPerson))
    }
  }
GABurns/ExamplePackage documentation built on Jan. 7, 2022, 12:24 a.m.