Import stock prices
stocks <- tq_get(c("JNJ", "KSS", "TDS"),
get = "stock.prices",
from = "2017-01-01",
to = "2019-01-01")
stocks
## # A tibble: 1,506 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 JNJ 2017-01-03 116. 116 115. 116. 5953000 93.8
## 2 JNJ 2017-01-04 116. 116. 115. 116. 5828900 93.7
## 3 JNJ 2017-01-05 116 117. 115. 117. 6217200 94.6
## 4 JNJ 2017-01-06 117. 117 116. 116. 5221400 94.2
## 5 JNJ 2017-01-09 116. 117. 116. 116. 5457500 94.2
## 6 JNJ 2017-01-10 116. 117 116. 116. 5312800 94.1
## 7 JNJ 2017-01-11 116. 116. 114. 115. 8887200 92.9
## 8 JNJ 2017-01-12 114. 115. 113. 115. 6627300 92.8
## 9 JNJ 2017-01-13 115. 115. 114. 115. 4935200 92.8
## 10 JNJ 2017-01-17 114. 115. 114. 115. 6255400 93.0
## # ℹ 1,496 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
