Solution Developing Data Products

Carlos Vargas

2024-08-26

Solution for week 4. Developing Data Products:

Instruction

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.

Solution

library(plotly)

p1 <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, color=~iris$Species, mode='markers', type = "scatter")

p2 <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, z = ~Petal.Width,
type = "scatter3d", color=~iris$Species, mode='markers')

Figures

The figure sizes have been customised so that you can easily put two images side-by-side.


library(plotly)
#> Warning: package 'plotly' was built under R version 4.3.3
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 4.3.3
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout
p1 <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, color=~iris$Species, mode='markers', type = "scatter")
p1
p2 <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, z = ~Petal.Width,
type = "scatter3d", color=~iris$Species, mode='markers')
p2