domain(x=c(-5, 5), y=c(-5, 5)
domain(x=c(1, 5), y=c(1, 5)
domain(x=c(1,1), y=c(-1,1)))
domain(x=c(5,10), y=c(0,10)))
question id: drl-1
🟡 Loading...
Loading webR...
Exercise 1 Use the function named
domain(x=c(-5, 5), y=c(-5, 5)
domain(x=c(1, 5), y=c(1, 5)
domain(x=c(1,1), y=c(-1,1)))
domain(x=c(5,10), y=c(0,10)))
question id: drl-1
Using Active R chunk 2 draw a slice through the function along the line
In the slice_plot()
command below, you will need to replace __tilde-expression___
and __domain__
with the correct syntax.
Which of these expressions will accomplish the task?
slice_plot(twins(x, y=0) ~ x, domain(x=c(-5,5)))
slice_plot(twins(x) ~ x, domain(y=c(-5, 5)))
slice_plot(twins(x, y=0) ~ x, domain(x=c(-5, 5), y=c(-5, 5)))
slice_plot(twins(x, y=0) ~ x + y, domain(x=c(-5, 5), y=c(-5, 5)))
question id: drl-2
Exercise 2 Many printed tables are meant to be used as functions, as in Figure 1; you plug in the input values and read off the output.
temperature and relative humidity
temperature and wind speed
temperature, latitude, and longitude
question id: dd-01-1
Figure 1 shows three different functions:
The heat index in
The heat index in
A caution warning level.
For inputs of 70% relative humidity and
question id: dd-01-2
Increase by
Increase by
Increase relative humidity to 80%.
question id: dd-01-3
question id: dd-01-r
The table does not say.
question id: dd-01-5
question id: dd-01-6
Exercise 3 The model
There are no functions, just inputs.
Three identity functions, each of which takes a different input.
Four identity functions, each of which takes a different input.
Three identity functions, each of which takes a different input, and a fourth function, namely the constant function
question id: identity-constant
Exercise 4 Even if you don’t yet have a theoretical understanding of how to construct functions with multiple inputs from data, you can R/mosaic operations for doing so. A key function is fitModel()
, which like makeFun()
, constructs a function. And, like makeFun()
, you need to use a tilde expression to specify the model formula. But, unlike makeFun()
, you can leave it to the computer to find the parameters that will make the function align with data.
To illustrate, we can construct a housing-price model from the SaratogaHouses
data:
price()
function to inputs, we are using the names of the inputs explicitly. To write the command price(2000,3,2)
risks mixing up which input is which.Use the function in the ordinary way. For instance, here is what the model has to say about the anticipated sales price of a house with 2000 square feet of living area, three bedrooms, and two bathrooms.
For technical reasons, the functions created by fitModel()
have a lot of computer-programming jargon in them, as you can see by constructing the model itself and then looking at the function. But you will also see the values of the parameters found by fitModel()
.
Exercise 5 Auckland, New Zealand is in a field of dormant volcanos. The highest, at 193 meters above sea level, is Maungawhau. Formerly, tourists could drive to the peak and look down into the crater, as seen in the picture.
The initial creator of R, Ross Ihaka, teaches at the University of Auckland. His digitization of a topographic map is easily plotted, as here:
The z-axis is height and is in meters. The x- and y-axes are latitude and longitude, measured in 10-meter units from a reference point. (So,
Get used to the presentation of the surface plot and how to rotate it and zoom in. To see the crater more clearly, you can rotate the surface plot to look straight downwards, effectively presenting you with a color-coded contour plot. Moving the cursor over the surface will display the
question id: crater-location
question id: crater-color
If you were to climb up Maungawhau, at some point you would be at the same elevation as the low-point of the crater, even though you are outside the crater. Think of the contour that corresponds to that elevation. Let’s call it the “half-way” contour since it is roughly half-way up the volcano.
question id: crater-contour
Imagine that you are filling up the crater with water. At some point, the water rises to a level where it will spill over the lip of the crater.
question id: crater-lip