dice: Throw a fair dice (with a given number of sides) n times.

View source: R/data_fun.R

diceR Documentation

Throw a fair dice (with a given number of sides) n times.

Description

dice generates a sequence of events that represent the results of throwing a fair dice (with a given number of events or number of sides) n times.

Usage

dice(n = 1, events = 1:6)

Arguments

n

Number of dice throws. Default: n = 1.

events

Events to draw from (or number of sides). Default: events = 1:6.

Details

By default, the 6 possible events for each throw of the dice are the numbers from 1 to 6.

See Also

Other sampling functions: coin(), dice_2(), sample_char(), sample_date(), sample_time()

Examples

# Basics:
dice()
table(dice(10^4))

# 5-sided dice:
dice(events = 1:5)
table(dice(100, events = 5))

# Strange dice:
dice(5, events = 8:9)
table(dice(100, LETTERS[1:3]))

# Note:
dice(10, 1)
table(dice(100, 2))

# Note an oddity:
dice(10, events = 8:9)  # works as expected, but 
dice(10, events = 9:9)  # odd: see sample() for an explanation.

# Limits:
dice(NA)
dice(0)
dice(1/2)
dice(2:3)
dice(5, events = NA)
dice(5, events = 1/2)
dice(NULL, NULL)


ds4psy documentation built on Sept. 15, 2023, 9:08 a.m.