This is what I am doing to tabulate the sampling results:
> n <- 1000
> tabulate(sample.int(4, n, replace = TRUE))
[1] 238 255 247 260
I will need to do this millions of time with different values of n
. I don't care about the actual sequence of the sampling. All I need is the count in each bin.
Is there a built-in function that does this directly? It feels inefficient to do it in the way shown above.