top of page
Search

# Solve Counting and Probability Problems Using R | Hire Best R Programming Experts |Sample Project | Realcode4you

Project Instructions

In this project, you will use R to solve counting and probability problems. To gain the most benefit from this project, avoid calculating numeric values and entering them into R. Instead, use R to do all necessary calculations.

When working in RStudio, be careful with cloud drives. RStudio does not always play well with cloud drives’ longer file path names. You will be best served by using a local drive whenever possible until you are comfortable troubleshooting technical issues.

1. Create a new project called “Lastname-Project5”.

2. Create an R Script file within your project called “Lastname-Project5.R”.

3. Include your name, the date, and the class in a comment as the first line of the script.

You can evaluate your project using the project5_tests.R test file. This will only work if you store results in the exact variable names specified in bold and in parentheses at the end of the problem.

Problems

Using the ball-dataset.

1. Download the data set ball-dataset.csv and read it into your script. Each ball in the dataset is represented by a color (red, blue, green, or yellow) and a label (A, B, C, D, or E).

2. Create a frequency table as a data.frame or tibble that contains counts for each color of ball (freq_color).

3. Create a frequency table as a data.frame or tibble that contains counts for each label of ball (freq_label).

4. Create a bar chart of the ball data set representing the counts of the different colors.

5. Create a bar chart of the ball data set representing the counts of the different labels.

6. What is the probability of drawing a green ball (prob6_result)?

7. What is the probability of drawing a blue or a red ball (prob7_result)?

8. What is the probability of drawing a ball with a label of A or C (prob8_result)?

9. What is the probability of drawing a yellow ball with a D (prob9_result)?

10. What is the probability of drawing a yellow ball or a ball with a D (prob10_result)?

11. What is the probability of drawing a blue ball followed by a red ball without replacement (prob11_result)?

12. What is the probability of drawing four green balls in a row without replacement (prob12_result)?

13. What is the probability of drawing a red ball followed by a ball with a B without replacement (prob13_result)?

14. [Challenge] Write the factorial function that computes the factorial of a given number.

– Recall that factorial (0) = 0

– factorial(3) = 6

– factorial(5) = 120

– For this problem you should handle all negative inputs as returning the value -1.

• factorial(-10) = -1.

Creating a coin flipping data frame

For the following problems, consider an unfair coin that has a probability .6 of landing on heads.

18. Manually create a data.frame or tibble that contains all possible outcomes of flipping the coin four times (coin_outcomes).

19. Compute the probability of each row outcome and store it as a column in the data.frame or tibble. You can do this manually or programmatically (coin_outcomes).

20. There are 5 possible outcomes in our coin dataset if we count the number of heads in each row. For example, the row “H H H H” has 4 heads and the row “H T H T” has 2 heads. Compute the probability of each of the 5 possible outcomes (num_heads_prob).

21. What is the probability of an outcome of three heads (prob21_result)?

22. What is the probability of an outcome of two heads or four heads (prob22_result)?

23. What is the probability of an outcome of less than or equal to three heads (prob23_result)?

24. Create a bar chart where the x-axis is the outcome and the y-axis is the probability.

Soccer Games (Optional Challenge Problems)

The following problems consider a soccer team with a 75% chance of winning a game at home and a 50% chance of winning away games. Consider that the team is about to play 10 games: five at home and five away.

25. What is the probability that they will win exactly 10 games (prob25_result)?

26. What is the probability that they will win more than one game (prob26_result)?

27. How many different ways could you pick five games at random and have three home games and two away games (prob27_result)?

If you need any help in R Programming Assignments and Projects then you can send your assignment requirement details at: