17 lines
343 B
R
17 lines
343 B
R
|
#'
|
||
|
#' Roll a die.
|
||
|
#'
|
||
|
#' Description.
|
||
|
#'
|
||
|
#' @param x A die to roll.
|
||
|
#' @param times How many times the die should be rolled.
|
||
|
#' @return A numeric vector representing the die rolls.
|
||
|
#' @examples
|
||
|
#' roll(d20)
|
||
|
#' roll(d20, times=10)
|
||
|
#'
|
||
|
#' @export
|
||
|
roll <- function(x, times=1){
|
||
|
return(sample(x$numbers, size=times, replace=TRUE, prob=x$probs))
|
||
|
}
|