Question: how do i use the RStudio to put this in Rmarkdown without getting error message? The one that I'm having a problem with is in

how do i use the RStudio to put this in Rmarkdown without getting error message? The one that I'm having a problem with is in bold letters

# 4-sided die with values 1, 2, 3, 4 die = c (1, 2, 3, 4) ``` ```{r} # rolling two 4-side dice will give us 4*4 = 16 total roll combinations # get all the roll combinations by running expand.grid on two "die" rolls = expand.grid ( die, die) ``` ```{r} # create a vector to get the product of two die values in each roll rolls$product = rolls$Var1 * rolls$Var2 ``` ```{r} # create a function to get the product of the two dice in a random roll # the function takes two integer values as parameters to define the # number of faces of the two dice dieProduct = function ( die1faces, die2faces ){ #get the roll value of each die d1roll = sample ( 1:die1faces, 1, replace = T ) d2roll = sample ( 1:die2faces, 1, replace = T ) ``` ```{r} #get the product of the two die rolls prod = d1roll * d2roll return (prod) } ``` ```{r} # Replicate 10,000 rolls of the four sided die # Initialize an empty vector rolled_values = c () for ( i in c (1:10000) ){ # get the product of the roll of two 4-sided dice current_roll = dieProduct(4,4) # append the current value to the vector of rolled values rolled_values = append ( rolled_values, current_roll) } ``` ```{r} # Plot the results in a histogram hist (rolled_values) ```

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!