Question: Using RStudio, perform the following instructions I am stuck this lab involves R Studio, any help would be greatly appreciated ```{r setup, include=FALSE} knitr::opts_chunk$set(echo =

Using RStudio, perform the following instructions I am stuck this lab involves R Studio, any help would be greatly appreciated

```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library("mosaic") ```

Today, we will work with making and plotting multivariable functions in R Studio.

## Making multivariable functions

To create a multivariable function in R is much like a function of a single variable. We will still use the `makeFun` command; the only difference is that now we need to indicate two or more input variables separating them with an & sign.

**Create the function of three input variables f(x,y,z)=x^2+7y-z. The inputs should be put to the right of the ~ as x&y&z. Make sure to assign this function a name (f is fine), so you can use it later.**

Now, suppose we want to input x=3, y=4, and z=5 into the function.

**Evaluate f(3,4,5). And double-check that this gives you the correct value for the function at these points**

R is interpreting the 3,4,5 as being placed in the same order you used for the input variables, x&y&z. If you had switched the order for some reason, but still put in 3,4,5 into f, you would not get the correct function. Let's try it!

**Create the same function, but let's call it g, and put the inputs as z&x&y. Then, type g(3,4,5).**

You'll notice you get an incorrect output which is different from when you plugged in f(3,4,5). To remedy this, you can always specify which input you are putting into the function.

**Evaluate f(x=3,y=4,z=5), f(z=5,y=4,x=3), g(y=4,z=5,x=3).**

Notice, when you specify which numeric value goes with which input, you always get the correct answer, so this is a good rule of thumb to follow.

**Create the two-variable function W(T,V) where W is wind chill, T is temperature in degrees Fahrenheit, and V is wind speed in miles per hour. The formula for W is W = 35.74 + 0.6215T - 35.75 V^0.16 + 0.4275TV^0.16**

**Look up the current temperature and wind speed. Assign these the variables currenttemp and currentwindspeed (You'll use these values later). Plug these in to determine the current wind chill.**

## Plotting functions of two inputs

Hopefully by now you have realized that R can do many things that your calculator cannot do. But our present task -- plotting a function of two variables -- is another great example. You already know most of what you need to know in order to do this. The `plotFun` command is the relevant one. We just need to provide it with a little extra information for functions of two variables, and we perhaps tweak some of the plotting options.

We will create the function x^2-y^2 as first a contour diagram and then a surface plot.

```{r} h=makeFun(x^2-y^2~x&y) #Contour Plot plotFun(h(x,y)~x&y,xlim=range(-5,5),ylim=range(-5,5)) ```

You see a graph that has some contours and some shading. The shading is to help give you a feel for what happens between the contours. However, if you want to turn off the colors, you can do the following. ```{r} plotFun(h(x,y)~x&y,xlim=range(-5,5),ylim=range(-5,5),filled=FALSE) ```

Now, let's graph the surface plot.

```{r} #Surface Plot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!