rflip: Coin flip.

View source: R/rflip.R

rflipR Documentation

Coin flip.

Description

Flip a coin 2000 times or fewer.

Usage

rflip(n = 1, prob = 0.5, quiet = FALSE, verbose = !quiet)

## S3 method for class 'cointoss'
print(x, ...)

Arguments

n

Integer. The number of times to flip the coin.

prob

Number between 0 and 1. The probability of getting a "head". Default value is 0.5.

quiet

Logical. Should a message be printed with the output? Default is FALSE, meaning a message will be printed.

verbose

Logical. The opposite of quiet from above. Should a message be printed? Default value is TRUE. Note, either quiet or verbose can be specified, but not both.

x

an object

...

additional arguments

Examples

# Basic usage. Note the printed output.
rflip()

# The printed output can be turned off using either method:
rflip(quiet = TRUE)
rflip(verbose = FALSE)

# Flip an unfair coin many times
flips <- rflip(100, prob = 0.35)
flips

# The actual output is embedded as an attribute
attr(flips, "sequence")

# Create a bargraph of the output
flips_output <- attr(flips, "sequence")
bargraph(~flips_output)


mobilizingcs/mobilizr documentation built on Feb. 17, 2024, 7:49 p.m.