Primary Dataset & Environment Setup

dat<- as_tibble(diamonds)
dat
## # A tibble: 53,940 × 10
##    carat cut       color clarity depth table price     x     y     z
##    <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1  0.23 Ideal     E     SI2      61.5    55   326  3.95  3.98  2.43
##  2  0.21 Premium   E     SI1      59.8    61   326  3.89  3.84  2.31
##  3  0.23 Good      E     VS1      56.9    65   327  4.05  4.07  2.31
##  4  0.29 Premium   I     VS2      62.4    58   334  4.2   4.23  2.63
##  5  0.31 Good      J     SI2      63.3    58   335  4.34  4.35  2.75
##  6  0.24 Very Good J     VVS2     62.8    57   336  3.94  3.96  2.48
##  7  0.24 Very Good I     VVS1     62.3    57   336  3.95  3.98  2.47
##  8  0.26 Very Good H     SI1      61.9    55   337  4.07  4.11  2.53
##  9  0.22 Fair      E     VS2      65.1    61   337  3.87  3.78  2.49
## 10  0.23 Very Good H     VS1      59.4    61   338  4     4.05  2.39
## # ℹ 53,930 more rows

Feature Analysis: Diamond Carat vs. market Price

For my first figure, I am going to create a scatterplot that plots diamond weight (carat) on the x-axis and price on the y-axis to see their relationship.

In the code chunk below, show your work filtering the data and create the subset of data you will display graphically.

fig_dat1 <- dat %>% select(carat, price)
fig_dat1
## # A tibble: 53,940 × 2
##    carat price
##    <dbl> <int>
##  1  0.23   326
##  2  0.21   326
##  3  0.23   327
##  4  0.29   334
##  5  0.31   335
##  6  0.24   336
##  7  0.24   336
##  8  0.26   337
##  9  0.22   337
## 10  0.23   338
## # ℹ 53,930 more rows

Categorical Assessment: Valuation Across Cut Quality

For my second figure, I am going to create a boxplot that shows the distribution of diamond prices across different cut qualities (Fair, Good, Very Good, Premium, Ideal).

fig_dat2 <- dat %>% select(cut, price)
fig_dat2
## # A tibble: 53,940 × 2
##    cut       price
##    <ord>     <int>
##  1 Ideal       326
##  2 Premium     326
##  3 Good        327
##  4 Premium     334
##  5 Good        335
##  6 Very Good   336
##  7 Very Good   336
##  8 Very Good   337
##  9 Fair        337
## 10 Very Good   338
## # ℹ 53,930 more rows

Conditional Data Filtering(Filtered Density Subsetting)

For my third figure, I will display a density plot of the price, specifically filtering only for diamonds that have an ‘Ideal’ cut quality.

fig_dat3 <- dat %>% filter(cut == "Ideal") %>% select(price)
fig_dat3
## # A tibble: 21,551 × 1
##    price
##    <int>
##  1   326
##  2   340
##  3   344
##  4   348
##  5   403
##  6   403
##  7   403
##  8   404
##  9   404
## 10   405
## # ℹ 21,541 more rows