From 6ce74680da25befb3e68d0d37ea3a1d1efb8c5b4 Mon Sep 17 00:00:00 2001 From: "Abner H.B." Date: Fri, 29 Mar 2024 16:39:07 -0400 Subject: [PATCH] Specified that dice should be six-sided and added bonus exercise --- 02_getting_started_with_r.qmd | 4 +++- docs/02_getting_started_with_r.html | 3 ++- docs/search.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/02_getting_started_with_r.qmd b/02_getting_started_with_r.qmd index bd742b5..e64aad6 100644 --- a/02_getting_started_with_r.qmd +++ b/02_getting_started_with_r.qmd @@ -684,4 +684,6 @@ All of the objects that we create inside a function will disappear after it fini Let's try to practice all of the basic features of **[R]{.sans-serif}** that you just learned. -Write a function that can simulate the roll of a pair of dice (let's call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function `sample()`. \ No newline at end of file +Write a function that can simulate the roll of a pair of six-sided dice (let's call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function `sample()`. + +Bonus: modify your function so that the dice can have different numbers of faces. \ No newline at end of file diff --git a/docs/02_getting_started_with_r.html b/docs/02_getting_started_with_r.html index ae45e42..76c838c 100644 --- a/docs/02_getting_started_with_r.html +++ b/docs/02_getting_started_with_r.html @@ -1052,7 +1052,8 @@

2.9 Exercise

Let’s try to practice all of the basic features of R that you just learned.

-

Write a function that can simulate the roll of a pair of dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function sample().

+

Write a function that can simulate the roll of a pair of six-sided dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function sample().

+

Bonus: modify your function so that the dice can have different numbers of faces.

diff --git a/docs/search.json b/docs/search.json index 48500f4..dda5bcb 100644 --- a/docs/search.json +++ b/docs/search.json @@ -123,7 +123,7 @@ "href": "02_getting_started_with_r.html#exercise", "title": "2  Getting Started with R", "section": "2.9 Exercise", - "text": "2.9 Exercise\nLet’s try to practice all of the basic features of R that you just learned.\nWrite a function that can simulate the roll of a pair of dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function sample()." + "text": "2.9 Exercise\nLet’s try to practice all of the basic features of R that you just learned.\nWrite a function that can simulate the roll of a pair of six-sided dice (let’s call them red and blue) an arbitrary number of times. This function should return a vector with the values of the red die that were strictly larger than the corresponding values of the blue die. Hint: to simulate rolling a die, you can use the function sample().\nBonus: modify your function so that the dice can have different numbers of faces." }, { "objectID": "05_data_for_analysis.html#creating-data-random-numbers",