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