Question: Homework 4 (17 pts) For this activity, you will create a .Rmd file and a corresponding HTML file that will both be uploaded to

Homework 4 (17 pts) For this activity, you will create a .Rmd file and a corresponding HTML file that will both be uploaded to wolfware. See the R file submission guidelines for all requirements - substantial credit may be taken off if the guidelines are not followed. The purpose of this activity is to practice writing functions, using for loops, and using vectorized functions. Loops/Function 1) (3 pts) Create a for loop to find the value of 10 factorial (10! = 10*9*8*..*1). Initialize an object to store the value in (a vector of length 1 set to 1 will work). Iterate from 1 to 10, multiplying and overwriting the value at each iteration of the loop 2) (6 pts) Now write a function that finds the factorial of a given number (so only one input, the number to find the factorial of). Set the default value to find to 10 Put in an if statement to check if the value of interest is greater than 100. If it is, stop the function and return a message saying the value is too large. If it isn't, compute the factorial. More Function Writing 3. (3 pts) Create a function called convert_cm_to_in that converts centimeters to inches. Use your function to determine how many inches a 25cm object is. Next, evaluate your function at a vector of integers from 0 to 100 (1 meter). 4. (1 pt) Add an addition input to the function that rounds the result to two decimal places by default. Rerun your function on the vector from 0 to 100. 5. (4 pts) Create a function called count_my_change that adds up the total amount of money you input. Include 5 arguments dollars, quarters, dimes, nickels, and pennies - Set the default value of ALL the arguments to 0 Calculate a total value by multiplying each argument by its dollar value (i.e. 0.25 quarters, 0.01 pennies, etc.) Create a string that says "Your total is Samount" with the total, and put it inside a return statement to send it back to the user. Try out the function with no inputs. Then try it with 5 dollars, 2 dimes, 3 quarters, 4 pennies, and 1 nickel. End of Activity Go back through and check that you have completed all questions. Upload both the .Rmd and the outputted .pdf file to moodle.
Step by Step Solution
There are 3 Steps involved in it
Sure Heres how you can approach ... View full answer
Get step-by-step solutions from verified subject matter experts
