5/27/2020

Instructions

Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity!

The rubric contains the following two questions:

  1. Does the web page feature a date and is this date less than two months before the date that you’re grading this assignment?
  2. Is the web page a presentation and does it feature an interactive plot that appears to have been created with Plotly?

Load and Prepare Data

library(plotly)
data <- diamonds[sample(nrow(diamonds), 2500), 
                 c("carat", "price", "clarity", "depth")]
summary(data)
     carat            price          clarity        depth      
 Min.   :0.2000   Min.   :  336   SI1    :639   Min.   :55.50  
 1st Qu.:0.4000   1st Qu.:  936   VS2    :546   1st Qu.:61.10  
 Median :0.7100   Median : 2444   SI2    :449   Median :61.90  
 Mean   :0.8063   Mean   : 3989   VS1    :368   Mean   :61.81  
 3rd Qu.:1.0400   3rd Qu.: 5320   VVS2   :248   3rd Qu.:62.50  
 Max.   :3.4000   Max.   :18766   VVS1   :140   Max.   :79.00  
                                  (Other):110                  

Create 2D and 3D Scatter Plots

p1 <- plot_ly(data, x = ~carat, y = ~price, color = ~carat,
        size = ~carat, text = ~paste("Clarity: ", clarity))
p2 <- plot_ly(data, x = ~carat, y = ~price, z = ~depth,
        color = ~carat, size = ~carat, 
        text = ~paste("Clarity: ", clarity)) 

Show 2D Scatter Plot

Show 3D Scatter Plot

Thank You