DndDice/R/makeDie.R

26 lines
808 B
R
Raw Permalink Normal View History

2019-03-19 03:56:07 +00:00
#'
#' Create a custom die.
#'
#' @param numbers A vector of the numbers that the die can roll on
#' @param probs A vecor of the probabilities for the numbers that the die can
#' roll on. By default the probabilities are assumed to be equal.
#' @return A \code{Die} object containing a vector of numbers the die can roll
#' on, as well as a vector of probabilities. It also has a text label set.
#' @seealso \code{\link{mean.Die}}, \code{\link{plot.Die}},
#' \code{\link{summary.Die}}, and \code{\link{print.Die}}.
#' @examples
#' stealth <- makeDie(1:20+3)
#' summary(stealth)
#'
#' @export
makeDie <- function(numbers, probs=NULL){
if(is.null(probs)){
probs = rep(1 / length(numbers), times=length(numbers))
}
die = list(numbers=numbers, probs=probs)
class(die) <- "Die"
return(die)
}