⚠️There's a newer version (1.0.0) of this package. Take me there.

tidydice

Simulates Dice Rolls and Coin Flips.

Introduction

A basic understanding of probability and statistics is crucial for data understanding. A great way to teach probability and statistics is to start with an experiment, like rolling a dice or flipping a coin.

This package simulates rolling a dice and flipping a coin. Each experiment generates a tibble. Dice rolls and coin flips are simulated using sample(). The properties of the dice can be changed, like the number of sides. A coin flip is simulated using a two sided dice. Experiments can be combined with the pipe-operator.

Installation

CRAN

install.packages("tidydice")

DEV version (github)

# install from github
if (!require(devtools)) install.packages("devtools")
devtools::install_github("rolkra/tidydice")

if you are behind a firewall, you may want to:

  • Download and unzip the tidydice package
  • Then install it with devtools::install_local
# install local
if (!require(devtools)) install.packages("devtools")
devtools::install_local(path = <path of local package>, force = TRUE)

Example

# load packages
library(tidyverse)
library(tidydice)

# roll a dice
roll_dice()

# roll a dice 6x
roll_dice(times = 6)

# roll a dice 6x and plot result
roll_dice(times = 6) %>% 
  plot_dice()

# repeat 6x
roll_dice(times = 6, rounds = 6) %>% 
  plot_dice()

# count success per round
roll_dice(times = 6, rounds = 6, agg = TRUE)

# Binomial distribution
binom_dice(times = 6)
  
# Binomial distribution + plot
binom_dice(times = 6) %>% 
  plot_binom()

# Binomial distribution + plot 
binom_dice(times = 6) %>% 
  plot_binom(highlight = 0:2)

Copy Link

Version

Down Chevron

Install

install.packages('tidydice')

Monthly Downloads

222

Version

0.0.6

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

January 9th, 2020

Functions in tidydice (0.0.6)