Question: The objective of this question is to introduce the matplot() function and give further practice with optional arguments and low level functions. (a) Compute the

The objective of this question is to introduce the matplot() function and give further practice with optional arguments and low level functions.

(a) Compute the mean price for each color and cut combination in the diamonds data, and store the result. The result should be a matrix object, where the rows correspond to the levels of color and the columns correspond to the levels of cut. Hint: This computation can be done with one command.

(b) The matplot() function plots columns of a matrix (or plots columns of one matrix against the columns of another). Use the matplot() function on the output from (a) to create line plot with a separate line for each level of cut.

Distinguish each line by separate line types, line widths, and/or colors of your choice.

Use the xaxt = "n" argument to suppress the tick marks and labels on the x-axis, then use the axis() function to set the x-axis labels to be the levels of the color variable.

Add a legend that explains the differences in the lines in the plot.

(c) Interpret the line plot from (b). Does it appear that the mean price of diamonds differs for different levels of color? For different levels of cut? Which levels tend to have higher mean prices?

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 Mathematics Questions!