Rolling a dice is simulated using sample(). The default dice has 6 sides and is fair. The properties of the dice can be changed. The result is returned as a tibble.
roll_dice(data = NULL, times = 1, rounds = 1, success = c(6),
agg = FALSE, sides = 6, prob = NULL, seed = NULL)
Data from a previous experiment
How many times a dice is rolled (or how many dice are rolled at the same time)
Number of rounds
Which result is a success (default = 6)
If TRUE, the result is aggregated (by experiment, rounds)
Number of sides of the dice (default = 6)
Vector of probabilities for each side of the dice
Seed to produce reproducible results
Result of experiment as a tibble
# NOT RUN { # rolling a dice once roll_dice() # rolling a dice 10 times roll_dice(times = 10) # aggregate result roll_dice(times = 10, agg = TRUE) # rounds roll_dice(times = 10, rounds = 3, agg = TRUE) # experiments library(dplyr) roll_dice(times = 10, rounds = 3, agg = TRUE) %>% roll_dice(times = 12, rounds = 3, agg = TRUE) # }
Run the code above in your browser using DataCamp Workspace