Skip to content
Prev 126394 / 398500 Next

Dice simulation: Getting rep to re-evaluate sample()?

I'm trying to get R to simulate the sum of the values on 10 fair dice
(yes, it's related to a homework problem, but is not the problem
itself). I tried to do this:
[1] 341 341 341 341 341 341 341 341 341 341
 
and noticed that sum(sample()) seems to be only evaluated once. How can
I overcome this, so that I get a vector of values that correspond to
independent throws of 10 dice each time?

Thanks for your advice and suggestions.

-Kevin

Kevin Zembower
Internet Services Group manager
Center for Communication Programs
Bloomberg School of Public Health
Johns Hopkins University
111 Market Place, Suite 310
Baltimore, Maryland  21202
410-659-6139