25 lines
808 B
R
25 lines
808 B
R
#'
|
|
#' 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)
|
|
}
|