7/27/2020

Introduction

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!

Visualization Code 1

Through this code we try to plot the closing prices of major European stock indices in the years of 1991 to 1998.

suppressPackageStartupMessages(library(plotly))
suppressPackageStartupMessages(library(tidyr))
suppressPackageStartupMessages(library(dplyr))
data("EuStockMarkets")
stocks <- as.data.frame(EuStockMarkets) %>%
  gather(index, price) %>%
  mutate(time = rep(time(EuStockMarkets), 4))
plot_ly(stocks, x = ~time, y = ~price, color = ~index, mode = "lines")

Visualization Plot 1

Visualization Code 2

Using the mtcars dataset we plot can attempt to understand the relationship of various factors to gas mileage (mpg).

We plot weight (wt) vs. mileage (mpg) spatially along the x/y axes. We visualize the number of cylinders (cyl) as colors and the amount of horsepower (hp) as the size of an individual point in the plot.

suppressPackageStartupMessages(library(plotly))
plot_ly(data = mtcars, x = ~wt, y = ~mpg, 
        color = ~as.factor(cyl), size = ~hp,
        text = ~paste("Weight: ", wt, '<br>MPG:', mpg),
        type = "scatter", mode = "markers") %>%
        layout(title = "Car Data")

Visualization Plot 2