Import stock prices
stocks <- tq_get(c("rrgb", "tsla"),
get = "stock.prices",
from = "2016-01-01")
stocks
## # A tibble: 4,868 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 rrgb 2016-01-04 60.9 61.4 59.6 59.9 190100 59.9
## 2 rrgb 2016-01-05 59.8 61.2 58.6 58.9 237900 58.9
## 3 rrgb 2016-01-06 58.4 60.0 58.4 59.3 269200 59.3
## 4 rrgb 2016-01-07 58.4 59.0 56.5 56.6 295300 56.6
## 5 rrgb 2016-01-08 56.8 58.5 56.8 58.3 275000 58.3
## 6 rrgb 2016-01-11 58.7 60.5 58.1 59.5 254700 59.5
## 7 rrgb 2016-01-12 59.8 60.9 58.4 60.6 237400 60.6
## 8 rrgb 2016-01-13 61.0 61.0 57.9 58 375100 58
## 9 rrgb 2016-01-14 58.1 58.3 55.8 58.0 457700 58.0
## 10 rrgb 2016-01-15 56.6 59.3 56.2 59.1 356000 59.1
## # ℹ 4,858 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
