Skip to content
Prev 168947 / 398506 Next

New to R

If you are interested in rolling dice with R (as opposed to using this as a simple test case to start writing your own programs), then you may want to look at the "dice" function from the TeachingDemos package.  The core line in this function is basically the same as Gabor's suggestion, but with the added option of weighting the dice (you don't like how I graded your exam? I am happy to let these computerized dice regrade it for you :-).  There is also an option to plot the results (for 6-sided dice).

There is also the plot.rgl.die and roll.rgl.die functions in the same package that give an animated rolling of the die (I really need to rewrite it to get a better animation, the coin flip works ok as is).

Hope this helps,