d: Create a die

Description Usage Arguments Details Value See Also Examples

View source: R/dice.R

Description

Create an instance of the Dice S4 class, allowing for the use of non-standard dice and for interactive dice rolling without having to recur to functions of the roll family. See below for more details.

Usage

1
d(faces)

Arguments

faces

Either the number of faces (length(faces) == 1) or a numeric vector specifying the values of the faces.

Details

If given a numeric vector, d() creates an object of the Dice S4 class representing a die with these values for faces. On the other hand, if given a numeric scalar, it creates a die with faces running from 1 to this value. At the moment, there is no support for specifying each face's probability, although it is possible to create a die where more than one face have the same value.

This function has two main purposes: creating non-standard dice and allowing for interactive dice rolling. Non-standard dice are arbitrary objects that might not have a real world counterpart, e.g., a d(17) or a d(c(1, 1, 3)). Interactive rolling is the ability to get a random result from a die without having to resort to functions of the roll family, explained in detail in the documentation for the Dice S4 class.

Value

An object of the Dice S4 class.

See Also

Dice, roll.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create a d6
d6 <- d(6)
d6

# Create a die with even faces
dEven <- d(c(2, 4, 6))
dEven

# Create a loaded die
dLoaded <- d(c(1:6, 6))
dLoaded

droll documentation built on Aug. 7, 2021, 1:05 a.m.

Related to d in droll...