Consider the function y fx defined by Suppose that you are

Consider the function y = f(x) defined by Suppose that you are given x, write an R function to calculate y = f(x) using if statements. Use your function in (a) to compute the values of y (called y. values) for given a set of values of x as x. values

Solution

a)))))))

myfunction <- function(x)
{
if (x<=0)
{
y=x^3;
}
if ((x>0)&&(x<=1))
{
y=x^2;
}
if (x>1)
{
y=x^(1/2);
}
return(y)
}

c)))) plot(x,y) // simple plot

 Consider the function y = f(x) defined by Suppose that you are given x, write an R function to calculate y = f(x) using if statements. Use your function in (a)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site