Import stock prices
stocks <- tq_get(c("WMT", "TGT"),
get = "stock.prices",
from = "2025-01-01",
to = "2026-01-01")
stocks
## # A tibble: 500 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 WMT 2025-01-02 90.0 90.6 89.5 90 14820400 88.6
## 2 WMT 2025-01-03 90.2 91.3 90.1 90.8 10834600 89.4
## 3 WMT 2025-01-06 90.8 92.5 90.7 91.4 14519900 90.0
## 4 WMT 2025-01-07 91.7 91.9 90.4 90.8 11238000 89.4
## 5 WMT 2025-01-08 91.1 91.8 90.8 91.8 13453600 90.4
## 6 WMT 2025-01-10 92.5 93.6 92.2 93 18140900 91.5
## 7 WMT 2025-01-13 92.1 92.4 91.1 91.5 18617100 90.1
## 8 WMT 2025-01-14 91.9 92.0 90.6 90.8 13549200 89.4
## 9 WMT 2025-01-15 91.1 91.7 90.8 91.3 17348200 89.9
## 10 WMT 2025-01-16 91.5 91.7 90.1 91.3 13267700 89.9
## # ℹ 490 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
