Course Project Presentation

Arshad Ullah
Sep 15, 2019

Select a Diamond app

This is a simple app that will select and display diamonds from the diamonds dataset based on the user's input. The UI has two widgets for input.

  • A slider input for the price range
  • A numeric input for the carat size

It will output the following in the main panel:

  • A 3D scatter plot showing the diamonds within the selected price range and +-10% of the carat size
  • An error message if no diamonds are found within the price range and carat size specified

Code used to create the plot

The server code will filter out the rows from the diamonds dataset.

Let's say we pick a price range of 0 to 2000 USD and a carat size of 1.0 (the default values)

The number of diamonds displayed will be as follows.

library(tidyverse)
subDiamonds <- filter(diamonds, price > 0, price<2000) %>% filter(carat>0.9*1,carat<1.1*1) %>% mutate(color = factor(color,ordered = TRUE))
nrow(subDiamonds)
[1] 26

If no rows are selected, an error message will be printed instructing the user to pick a higher price range or lower carat size.

Output 3D Scatter plot

The output 3D scatter plot showing the diamonds picked is displayed with the x-axis as carat, y-axis as color and z-axis as the price. The color of the markers is based on the Cut and the size is based on the Depth.

alt text

Features of the plot

The actual 3D plot is interactive and displays a bunch of information when hovering over a particular marker. The information displayed are:

  • Price
  • Carat (weight of the diamond)
  • Cut (quality of the cut (Fair, Good, Very Good, Premium, Ideal))
  • Clarity (a measurement of how clear the diamond is (I1 (worst), SI2, SI1, VS2, VS1, VVS2, VVS1, IF (best)))
  • Depth (total depth percentage = z / mean(x, y) = 2 * z / (x + y) (43-79) where x, y and z are length, width and depth in mm)