When programming in R, how can I make a function that returns the amount of times I have to throw a set of five dice and get a “1,2,3,4,5” combination? Let’s say I’m using dice that have six sides and a maximum number of six. The function should also return the amount of times I have to throw them to get a “2,3,4,5,6”combination.

You can answer this a couple of ways. You could calculate the permutation, or run a bunch of simulations.

A quick check for R packages that support this kind of thing (and I should say that I personally haven't worked with these yet), it looks like the `Rdice`

package describes itself as "A collection of functions to simulate dice rolls and the like. In particular, experiments and exercises can be performed looking at combinations and permutations of values in dice rolls and coin flips, together with the corresponding frequencies of occurrences...", which seems like exactly what you're looking for on the simulation side of things.

A good way to move forward here would be to check out those packages that support these kinds of questions as a starting point. If you have questions or issues with your approach, pose it back here with a reproducible example.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Thank you, I’ll check it out