Import stock prices

stocks <- tq_get(c("WMT", "GM"),
                 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 WMT    2016-01-04  20.2  20.5  20.1  20.5 35967600     17.1
##  2 WMT    2016-01-05  20.7  21.0  20.6  21.0 39978000     17.5
##  3 WMT    2016-01-06  20.8  21.3  20.8  21.2 49693800     17.7
##  4 WMT    2016-01-07  21.0  21.7  21.0  21.7 79290000     18.1
##  5 WMT    2016-01-08  21.7  21.8  21.1  21.2 53303700     17.7
##  6 WMT    2016-01-11  21.3  21.5  21.2  21.4 37961400     17.9
##  7 WMT    2016-01-12  21.5  21.6  21.1  21.2 36587700     17.7
##  8 WMT    2016-01-13  21.2  21.2  20.6  20.6 41177100     17.2
##  9 WMT    2016-01-14  20.7  21.2  20.6  21.0 38804700     17.6
## 10 WMT    2016-01-15  20.5  20.8  20.4  20.6 45523200     17.2
## # ℹ 494 more rows

Plot stock prices

stocks %>%
    
    ggplot(aes(x = date, y = adjusted, color = symbol)) +
    geom_line()