Q1 1. Define a function "get.t1()". The input of the function is one numeric value "t2". The output is one numeric value

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Q1 1. Define a function "get.t1()". The input of the function is one numeric value "t2". The output is one numeric value

Post by answerhappygod »

Q1 1 Define A Function Get T1 The Input Of The Function Is One Numeric Value T2 The Output Is One Numeric Value 1
Q1 1 Define A Function Get T1 The Input Of The Function Is One Numeric Value T2 The Output Is One Numeric Value 1 (49.49 KiB) Viewed 28 times
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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply