Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Only answer all of part B in R. Give the R commands. Write an explicit stacked set of if statements that does the same thing
Only answer all of part B in R. Give the R commands.
Write an explicit stacked set of if statements that does the same thing as the integer version of the switch function illustrated earlier. Test it with mynum dosage [1] 10.0 60.0 60.0 60.0 10.0 25.3 25.3 ii. Using the same lowdose, meddose, and highdose thresholds as in (i), given doselevel dosage [1] 25.0 25.0 25.0 83.4 25.0 83.4 83.4 Also, doselevel has been overwritten as follows: R> doselevel [1] Small Small Small Large Small Large Large Levels: Small Large iii. Given lowdose dosage [1] 9 49 49 Also, doselevel has been overwritten as follows: R> doselevel 1] Small Large Large Levels: Small Large iv. Using the same lowdose, meddose, and highdose thresholds as (iii), as well as the same doselevel as (i), the result of dosage after running the nested if statements is as follows: R> dosage [1] 4.5 91.5 91.5 91.5 4.5 26.0 26.0 Assume the object mynum will only ever be a single integer between 0 and 9. Use ifelse and switch to produce a command that takes in mynum and returns a matching character string for all possible values 0, 1, ..., 9. Supplied with 3, for example, it should return "three"; supplied with o, it should return "zero", Write an explicit stacked set of if statements that does the same thing as the integer version of the switch function illustrated earlier. Test it with mynum dosage [1] 10.0 60.0 60.0 60.0 10.0 25.3 25.3 ii. Using the same lowdose, meddose, and highdose thresholds as in (i), given doselevel dosage [1] 25.0 25.0 25.0 83.4 25.0 83.4 83.4 Also, doselevel has been overwritten as follows: R> doselevel [1] Small Small Small Large Small Large Large Levels: Small Large iii. Given lowdose dosage [1] 9 49 49 Also, doselevel has been overwritten as follows: R> doselevel 1] Small Large Large Levels: Small Large iv. Using the same lowdose, meddose, and highdose thresholds as (iii), as well as the same doselevel as (i), the result of dosage after running the nested if statements is as follows: R> dosage [1] 4.5 91.5 91.5 91.5 4.5 26.0 26.0 Assume the object mynum will only ever be a single integer between 0 and 9. Use ifelse and switch to produce a command that takes in mynum and returns a matching character string for all possible values 0, 1, ..., 9. Supplied with 3, for example, it should return "three"; supplied with o, it should return "zeroStep 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