Question
The question involves a dice rolling experiment using R. One fair die is rolled 10 times. I am trying to write a function that returns
The question involves a dice rolling experiment using R. One fair die is rolled 10 times.
I am trying to write a function that returns true if the number of even numbers observed in this experiment is greater than 5.
The first part of my function returns a random sample of 10 numbers for the die rolling and it works when using return(dice), but I am getting stuck after that to instead return true for observing more than 5 even numbers.
Here is what I have so far:
trial <- function(){
dice <- sample(1:6, size = 10, replace = True)
??}
Where I have the ??, what should I put next? I tried using a for loop and I couldn't get it to work. Is there another way to do it? Or what should the syntax be for the loop?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started