Diamond prices are driven by 4Cs: carat, cut, color, and clarity. In this assignment you’ll explore a dataset containing the prices and other attributes of almost 54,000 diamonds.
The data can be found in the ggplot2
package.
Load the package with
library(ggplot2)
and load the data with
data(diamonds)
Take a peek at the codebook with
?diamonds
The figure below can be helpful for understanding what the variables in the dataset mean.
Carat is a unit of mass equal to 200 mg and is used for measuring gemstones and pearls. Cut grade is is an objective measure of a diamond’s light performance, or, what we generally think of as sparkle.
The figures below shows color grading of diamonds.
Lastly, the figure below shows clarity grading of diamonds:
Go to the #assignment-links channel on Slack and click on the link for mini-hw-07, and accept the assignment. Note that this is an individual assignment.
Answer each of the following in a single pipe. You do not need to provide any interpretations, only the code and output is sufficient.
How many diamonds of each type of cut are there?
Calculate the relative frequency of each clarity of diamonds.
Plot the relationship between depth and price of only fair cut diamonds.
For each type of cut, calculate minimum (min
), maximum (max
), mean (mean
), and median (median
) price of diamonds of that type.
Total | 15 pts |
---|---|
Questions 2 - 4 | 2 pt / question - 6 pts |
Questions 1 and 5 | 3 pts / question - 6 pts |
Code style and informatively named code chunks | 1 pt |
Commit frequency and informative messages | 1 pt |
Overall organization | 1 pt |