Import stock prices

stocks <- tq_get(c("NVDA", "MSFT","INTC","DELL","SONY","GOOG","APPL"))
## Warning: There was 1 warning in `dplyr::mutate()`.
## ℹ In argument: `data.. = purrr::map(...)`.
## Caused by warning:
## ! x = 'APPL', get = 'stock.prices': Error in getSymbols.yahoo(Symbols = "APPL", env = <environment>, verbose = FALSE, : Unable to import "APPL".
## attempt to set an attribute on NULL
##  Removing APPL.
                 get = "stock.prices"
                 from = "2016-01-01"
stocks
## # A tibble: 15,683 × 8
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 NVDA   2015-01-02 0.503 0.507 0.495 0.503 113680000    0.483
##  2 NVDA   2015-01-05 0.503 0.505 0.493 0.495 197952000    0.475
##  3 NVDA   2015-01-06 0.495 0.496 0.479 0.480 197764000    0.461
##  4 NVDA   2015-01-07 0.483 0.488 0.477 0.479 321808000    0.459
##  5 NVDA   2015-01-08 0.484 0.500 0.484 0.496 283780000    0.477
##  6 NVDA   2015-01-09 0.498 0.502 0.491 0.498 209540000    0.479
##  7 NVDA   2015-01-12 0.500 0.5   0.488 0.492 190732000    0.473
##  8 NVDA   2015-01-13 0.496 0.506 0.488 0.491 236720000    0.472
##  9 NVDA   2015-01-14 0.486 0.495 0.485 0.493 155260000    0.474
## 10 NVDA   2015-01-15 0.497 0.5   0.490 0.490 188932000    0.470
## # ℹ 15,673 more rows

Plot stock prices

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