rep(
    sum(sample(1:6,100,replace=T)),
    times=10)

Read carefully what you wrote.  You asked R to sum a single sample, then
make
ten copies of the sum.

You need to take ten samples, then sum each.   apply() would be helpful.

-----Original Message-----
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:
> rep(sum(sample(1:6,100,replace=T)), times=10)
 [1] 341 341 341 341 341 341 341 341 341 341

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to