Set UP

library(tidyverse)
library(quantmod)
library(plotly)
library(tidyquant)

Data

Analzing Apple and Walmart

# Import stock prices
stocks <- tq_get(c("AAPL", "WMT"),
                 get = "stock.prices",
                 from = "2016-01-01",
                 to = "2017-01-01")
stocks
## # A tibble: 504 × 8
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 AAPL   2016-01-04  25.7  26.3  25.5  26.3 270597600     24.2
##  2 AAPL   2016-01-05  26.4  26.5  25.6  25.7 223164000     23.5
##  3 AAPL   2016-01-06  25.1  25.6  25.0  25.2 273829600     23.1
##  4 AAPL   2016-01-07  24.7  25.0  24.1  24.1 324377600     22.1
##  5 AAPL   2016-01-08  24.6  24.8  24.2  24.2 283192000     22.2
##  6 AAPL   2016-01-11  24.7  24.8  24.3  24.6 198957600     22.6
##  7 AAPL   2016-01-12  25.1  25.2  24.7  25.0 196616800     22.9
##  8 AAPL   2016-01-13  25.1  25.3  24.3  24.3 249758400     22.3
##  9 AAPL   2016-01-14  24.5  25.1  23.9  24.9 252680400     22.8
## 10 AAPL   2016-01-15  24.0  24.4  23.8  24.3 319335600     22.3
## # … with 494 more rows

Plots for Walmart and Apple

g <- ggplot(data = stocks) + 
  geom_point(mapping = aes(x = volume, y = adjusted, color = symbol))

g
Revenue by Category

Revenue by Category

Interactive Plot

ggplotly(g)

Static Plot

g <- ggplot(data = stocks) + 
  geom_point(mapping = aes(x = volume, y = adjusted, color = symbol))

g
Revenue by Category

Revenue by Category