New to R
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