-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
77 lines (54 loc) · 1.83 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
> ... iacta alea est
>
> -- <cite>[Gaius Julius Caesar][1]</cite>
[1]:https://en.wikipedia.org/wiki/Alea_iacta_est
# alea
R package for casting dice, including dice for [Dungeons & Dragons](http://dnd.wizards.com/) and special dice like the [Sicherman dice](https://en.wikipedia.org/wiki/Sicherman_dice).
## Overview
`alea` consists of one main function `cast_dice()` with parameters for different situations (see below) and several dice like `d4()`, `d20()`, `sicherman()` which can be used without additional parameters. The interface for the main function is `cast_dice(sides = 1:6, n_tries = 1, sum = FALSE)`.
* `sides`: can either be an integer value (maximum value on a standard dice) or a vector of sides. `6` and `1:6` both result in casting a 6-sided dice.
* `n_tries`: how often the dice should be cast.
* `sum`: whether the result of casting the dice should be summed.
## Installation
You can install alea from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("expectopatronum/alea")
```
Load the package:
```{r load-package}
library(alea)
```
## Other packages
Since casting dice is a rather important and easily programmed task, there exist a few other R package. I made a list of the ones I found and tried a few examples [here](misc/package_comparison.md).
## Examples
These examples show the usage of some of the dice in the package.
```{r seed}
set.seed(24) # this seed was randomly chosen by casting a d60
```
```{r ex1}
cast_dice()
```
```{r ex2}
cast_dice(20, 3)
```
```{r ex3}
cast_dice(c(2, 4, 6, 8, 10))
```
```{r ex4}
d20()
```
```{r ex5}
d6(4, TRUE)
```