rrandomdice

Calculating the Sum of specific dice rolls


I am trying to calculate the number of each specific dice roll. For example, I made a "random" generator of 100 dice rolls, all values between 1 and 6.

I want to add up the number of each roll. So, the number of 1s rolled, number of 2s rolled, and so on. This is what I have so far, but I am not sure where to start and what function to use to calculate these values. Thanks!

data_rolls = sample(1:6, size = 100, replace = TRUE)
data_rolls = data.frame(data_rolls)`

Solution

  • Try table():

    table(data_rolls)
    ## data_rolls
    ##  1  2  3  4  5  6 
    ## 13 16 18 14 21 18