Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help by coding all parts for problems in R through RMarkdown The objective of this question is to introduce the ifelse() function and give

please help by coding all parts for problems in R through RMarkdown

image text in transcribed

The objective of this question is to introduce the ifelse() function and give practice with vectorization. (a) Write a function called my _ifelse() that implements a vector form of the if-else statement without the ifelse() function. That is, the ith element of my ifelse (test, yes, no) will be yes [i] if test [i] is TRUE and no [i] if test [i] is FALSE. Values of yes or no should be recycled if either is shorter than test. Hint: This can be written as a loop, but a vectorized solution is better. (b) Verify that your my_ifelse() function works by executing the following commands: x < (1:10) pi my_ifelse(x %% 1 >= 0.5, x %/% 1 + 1, x %/% 1) (c) Use your my_ifelse() function to write my _abs() and my_sign() functions that, respectively, compute the absolute values and signs of the elements of a numeric vector. The respective outputs of my_abs (x) and my_sign() should be identical to abs(x) and sign(x) for any numeric vector x. Hint: It may be helpful to use my_abs () when writing my_sign().

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

Find a function (x, y) such that = (y, x).

Answered: 1 week ago

Question

whats the output

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago

Question

Difference between truncate & delete

Answered: 1 week ago