coin | R Documentation |
coin
generates a sequence of events that
represent the results of flipping a fair coin n
times.
coin(n = 1, events = c("H", "T"))
n |
Number of coin flips.
Default: |
events |
Possible outcomes (as a vector).
Default: |
By default, the 2 possible events
for each flip
are "H" (for "heads") and "T" (for "tails").
Other sampling functions:
dice_2()
,
dice()
,
sample_char()
,
sample_date()
,
sample_time()
# Basics:
coin()
table(coin(n = 100))
table(coin(n = 100, events = LETTERS[1:3]))
# Note an oddity:
coin(10, events = 8:9) # works as expected, but
coin(10, events = 9:9) # odd: see sample() for an explanation.
# Limits:
coin(2:3)
coin(NA)
coin(0)
coin(1/2)
coin(3, events = "X")
coin(3, events = NA)
coin(NULL, NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.