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!



Review Criteria 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?

Sys.time()
## [1] "2026-05-20 15:25:31 -05"
Sys.Date()
## [1] "2026-05-20"

First, loading the packages and libraries.

# Instalar los paquetes básicos necesarios
install.packages("plotly", repos = "https://cloud.r-project.org")
## 
##   There is a binary version available but the source version is later:
##        binary source needs_compilation
## plotly 4.10.4 4.12.0             FALSE
install.packages("sf", repos = "https://cloud.r-project.org")
## 
##   There is a binary version available but the source version is later:
##    binary source needs_compilation
## sf 1.0-20  1.1-1              TRUE
install.packages("ggplot2", repos = "https://cloud.r-project.org")
## 
##   There is a binary version available but the source version is later:
##         binary source needs_compilation
## ggplot2  3.5.1  4.0.3             FALSE
install.packages("leaflet", repos = "https://cloud.r-project.org")
## 
##   There is a binary version available but the source version is later:
##         binary source needs_compilation
## leaflet  2.2.2  2.2.3             FALSE
# Cargar las librerías para empezar a trabajar
library(plotly)
library(sf)
library(ggplot2)

Load the data

library(plotly)
data <- diamonds[sample(nrow(diamonds), 2500), 
                 c("carat", "price", "clarity", "depth")]
summary(data)
##      carat            price          clarity        depth      
##  Min.   :0.2000   Min.   :  345   SI1    :618   Min.   :54.00  
##  1st Qu.:0.4000   1st Qu.:  968   VS2    :575   1st Qu.:61.00  
##  Median :0.7000   Median : 2422   SI2    :404   Median :61.80  
##  Mean   :0.7918   Mean   : 3886   VS1    :385   Mean   :61.71  
##  3rd Qu.:1.0325   3rd Qu.: 5292   VVS2   :243   3rd Qu.:62.50  
##  Max.   :2.5300   Max.   :18571   VVS1   :166   Max.   :68.80  
##                                   (Other):109


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)) 


Display the plots 2D Plot

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

p1


Display the plots 3D Plot

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

p2