Question: Using R Studio solve for the following: (2)(a) Create a user-defined function - via *function()* that implements the trigonometric function above, accepts numeric values, x,
Using R Studio solve for the following:


(2)(a) Create a user-defined function - via *function()* that implements the trigonometric function above, accepts numeric values, "x," calculates and returns values "y." {r test2a} (2)(b) Create a vector, x, of 4001 equally-spaced values from -2 to 2, inclusive. Compute values for y using the vector x and your function from (2) (a). **Do not output x or y.** Find the value in the vector x that corresponds to the maximum value in the vector y. Restrict attention to only the values of x and y you have computed; i.e. do not interpolate. Round to 3 decimal places and output both the maximum y and corresponding x value. Finding the two desired values can be accomplished in as few as two lines of code. Do not use packages or programs you may find on the internet or elsewhere. Do not output the other elements of the vectors x and y. Relevant coding methods are given in the *Quick Start Guide for R*. '{r test2b} (2) (c) plot y versus x in color, with x on the horizontal axis. show the location of the maximum value of y determined in 2(b). Show the values of x and y corresponding to the maximum value of y in the display. Add a title and other features such as text annotations. Text annotations may be added via *text()* for base R plots and "geom_text()* or *geom_label()* for ggplots. {r test2c} (2)(a) Create a user-defined function - via *function()* that implements the trigonometric function above, accepts numeric values, "x," calculates and returns values "y." {r test2a} (2)(b) Create a vector, x, of 4001 equally-spaced values from -2 to 2, inclusive. Compute values for y using the vector x and your function from (2) (a). **Do not output x or y.** Find the value in the vector x that corresponds to the maximum value in the vector y. Restrict attention to only the values of x and y you have computed; i.e. do not interpolate. Round to 3 decimal places and output both the maximum y and corresponding x value. Finding the two desired values can be accomplished in as few as two lines of code. Do not use packages or programs you may find on the internet or elsewhere. Do not output the other elements of the vectors x and y. Relevant coding methods are given in the *Quick Start Guide for R*. '{r test2b} (2) (c) plot y versus x in color, with x on the horizontal axis. show the location of the maximum value of y determined in 2(b). Show the values of x and y corresponding to the maximum value of y in the display. Add a title and other features such as text annotations. Text annotations may be added via *text()* for base R plots and "geom_text()* or *geom_label()* for ggplots. {r test2c}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
