Read in the Amazon and Ali Baba closing stock prices between 9/24/16-9/24/17 from https://finance.yahoo.com

amzn <- read.csv("AMZN.csv", header=TRUE, sep = ",")
baba <- read.csv("BABA.csv", header=TRUE, sep = ",")

Convert Date from factor to date format

head(amzn$Date)
a <- as.Date(amzn$Date)
amzn$Date <- a

Create a dataframe from the two stocks’ closing prices

stocks <- data.frame(Date = amzn$Date, 
                     AMZN = round(amzn$Adj.Close,2),
                     BABA = round(baba$Adj.Close,2))

Use the plotly package to create an interactive graph of the stock prices

library(plotly)

p <-  stocks %>%
      plot_ly(x=~Date, y=~AMZN, type="scatter", fill="tozeroy", name="AMAZON") %>%
      add_trace(y=~BABA, type="scatter", fill="tonexty", name="ALI BABA") %>%
      layout(title = "24 Months Adjusted Closing Stock Prices",
             xaxis = list(title="Time"),
             yaxis = list(title="Stock Prices"))
p