2023-08-19

Synopsis

Following instructions have been given for the assignment:

  1. Create a web page presentation using R Markdown that features a plot created with Plotly.
  2. Host your webpage on either RPubs, GitHub Pages, or NeoCities.
  3. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly.

The Interactive Plots presented in this Assignment are as follows:

  1. A Line Graph with Error Bars depicting the Tooth Growth.
  2. A Basic 3D Surface Plot of a Volcano.

Interactive Plot 1: Line Graph with Error Bars R Code

library(plotly)
library(plyr)
data_mean <- ddply(ToothGrowth, c("supp", "dose"), summarise, 
                   length = mean(len))
data_sd <- ddply(ToothGrowth, c("supp", "dose"), summarise, 
                 length = sd(len))
data <- data.frame(data_mean, data_sd$length)
data <- rename(data, c("data_sd.length" = "sd"))
data$dose <- as.factor(data$dose)

fig1 <- plot_ly(data = data[which(data$supp == 'OJ'),], x = ~dose, 
               y = ~length, type = 'scatter', mode = 'lines+markers',
        name = 'OJ',
        error_y = ~list(array = sd,
                        color = '#000000'))
fig1 <- fig1 %>% add_trace(data = data[which(data$supp == 'VC'),], 
                         name = 'VC')
fig1

Interactive Plot 1: Line Graph with Error Bars

Interactive Plot 2: Basic 3D Surface Plot R Code

library(plotly)
# volcano is a numeric matrix that ships with R
fig2 <- plot_ly(z = ~volcano)
fig2 <- fig2 %>% add_surface()

fig2

Interactive Plot 2: Basic 3D Surface Plot

Thank You!