Joe Hughes wrote:
>
> #
> function(die_size, number_of_dice, number_of_rolls)
> {

you may want to replace

>     rolls <- array(0, dim=c(number_of_rolls, number_of_dice))
>     
>     for (i in 1:number_of_rolls)
>     {
>         rolls[i,] <- sample(die_size, number_of_dice, replace=TRUE)
>     }

with, e.g.

rolls = t(replicate(number_of_rolls, sample(die_size, number_of_dice,
replace=TRUE)))

to have it more r-ish

>     
>     return(rolls)
> }
>
> Any thoughts on this function?  

as soon as you start wrapping something like subset, lm, or the like
inside your functions, all hell breaks loose.  welcome to the r inferno,
that is. 


vQ

______________________________________________
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