Import stock prices

stocks <- tq_get(c("GD", "RTX", "LMT"),
                 get = "stock.prices",
                 from = "2010-01-01",
                 to = "2020-01-01")
stocks
## # A tibble: 7,548 × 8
##    symbol date        open  high   low close  volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>   <dbl>    <dbl>
##  1 GD     2010-01-04  68.5  69.2  68.2  69.2 1198500     51.1
##  2 GD     2010-01-05  69.3  69.8  68.8  69.3 1535400     51.2
##  3 GD     2010-01-06  69.0  69.4  68.8  69.2 1149700     51.1
##  4 GD     2010-01-07  69.1  69.5  68.7  69.4 1262300     51.3
##  5 GD     2010-01-08  69.4  69.7  68.9  69.4 1582000     51.3
##  6 GD     2010-01-11  69.8  70.8  69.7  70.7 1508400     52.2
##  7 GD     2010-01-12  70.3  70.7  69.8  70.3 1677200     51.9
##  8 GD     2010-01-13  70.2  71.5  70.0  71.1 1797800     52.8
##  9 GD     2010-01-14  70.9  71.2  70.3  71.1 2332600     52.8
## 10 GD     2010-01-15  71.1  71.1  69.8  70.6 1829400     52.4
## # … with 7,538 more rows

Plot stock prices

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