Q1 1. Define a function "get.t1()". The input of the function is one numeric value "t2". The output is one numeric value
Posted: Sun Jul 03, 2022 12:01 pm
Q1 1. Define a function "get.t1()". The input of the function is one numeric value "t2". The output is one numeric value. it is calculated as (t2-32) x 5/9. Within "get.t1()" function body, before calculating "t2", use two "stopifnot()" functions to evaluate o if input t2 is numeric. o if input t2 is length 1. 2. Call your "get.t1()" function with 64 as input. 3. Define a function "get.all()". The input of the function is a numeric vector "input.vec" with length >= 2. The output of the function is a numeric vector "output.vec". The "output.vec" has same length as "input.vec". The ith element in output.vec is "get.t1(input.vec)". Use for loop in the get.all() function. Call your function with c(32, 64) as input. 4. Define a vector "my.input" containing integers from 1 to 1000000. Call "get.all()" function with "my.input" as input. Report time consumption. 5. Remove the second "stopifnot()" function with in "get.t1()" so that "get.t10)" no longer evaluates if input "t2" is length 1. Then call "get.t1()" function with "my.input" vector as input. Can you get the same result like Q1.3? Why or why not (discuss by using only one sentence). Meanwhile, report time consumption.