• Background
  • Reading
  • Tasks
  • Data Wrangling & Visualization
  • Conclusions
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)

Background

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.

Reading

  • dygraphs for R
  • DT: An R interface to the Data Tables library
  • timekit R package

Tasks

  • Build the library(dygraphs) plot that shows the Kroger (KR) stock price performance over 5 years.
  • Imaging that you invested $10,000 in kroger about two years ago on April 5th. Make a graph with dygraph that shows performance dyRebase() to $10,000.
  • Annotate the graphic with a note of the reason at two or more time points, or intervals, where the price had significant shifts.
  • Create an .Rmd file with 1-2 paragraphs summarizing your graphics and the choices you made in the data presentation
  • Compile your .md and .html file into your git repository

Data Wrangling & Visualization

# Use this R-Chunk to wrangle & plot your data!
dygraph(kr)
18
20
22
24
26
28
30
32
34
36
38
40
Jul 2015
Jan 2016
Jul 2016
Jan 2017
Jul 2017
Jan 2018
Jul 2018
Jan 2019
Jul 2019
Jan 2020
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")
8500
9000
9500
10000
10500
11000
11500
12000
12500
13000
13500
14000
14500
15000
15500
Apr 2018
Jul 2018
Oct 2018
Jan 2019
Apr 2019
Jul 2019
Oct 2019
Jan 2020
B
A

Conclusions

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.