2025-03-11

The data

This presentation contains the main information for myShinyApp.

The data set of the app is the diamond data set from the ggplot2 package. This data set contains the prices and other attributes of almost 54,000 diamonds.

Here is the head of the data set:

## # A tibble: 6 × 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

How to use the app

This application can help yo to estimate the price (USD) of your diamond with a given weight (carat) based on your diamond type.

You can select:

  • the quality of the cut
  • the color of your diamond (D is the most valuable, J is the least)
  • the weight of your diamond (with 0.1 step)

The code:

The code for the plot in the next slide:

#data=diamonds
#data1 <- data[data$cut == "Fair" & data$color == "D", ]
#d=plot(data1$carat, data1$price, pch = 19, 
#                 xlab = "Carat",
#                 ylab = "Price",
#                 main = paste("Price per carat for Fair cut and D color"),
#                 xlim = c(0, 5), ylim = c(0, 20000))

A demo plot from the app.