sys_now <- now() - ddays(x = 1)
sys_minus_5yr <- sys_now - dyears(x = 5)
sys_minus_2yr <- sys_now - dyears(x = 2)
kroger <- tq_get(c("KR"), get = "stock.prices", from = sys_minus_5yr, to = sys_now) %>%
select(date, adjusted)
kr <- tk_xts(kroger)
Interactive visualizations can often be powerful for data investigations. They let your team get at questions in real time. Use the Kroger (KR) stock price to build an interactive visualization of their performance over the last five years. Take some time to build a couple of different visualizations that show Krogers performance. See the task items below for a description.
# Use this R-Chunk to wrangle & plot your data!
dygraph(kr)
dygraph(kr) %>%
dyRangeSelector(dateWindow = c(sys_minus_2yr, sys_now)) %>%
dyRebase(value = 10000) %>%
dyAnnotation("2019-07-23", text = "A", tooltip = "Drop") %>%
dyAnnotation("2018-09-07", text = "B", tooltip = "Raised")
I created a graph that shows the change in stocks of kroger. I picked a drop and a raise in the in the stock. I was able to incorporate lubridate in my wrangling.