DJIA Daily Closing Prices

Ramana Sonti
04/30/2017

Introduction

  1. Shiny with Plotly to create interactive charts
  2. sidebar layout with two input options (slider and dropdown) on the left
  3. main panel on the right displays the chart
  4. input selected from one widget is used to update the other input widget
  5. getSymbols from quantmod package to fetch data from yahoo

Market Data from yahoo

library(data.table)
library(quantmod)
library(dplyr)
library(zoo)

getSymbols('^DJI',src='yahoo', from='2002-01-01', to='2002-12-31')
[1] "DJI"
trends <- data.frame(Date = index(DJI), coredata(DJI)) %>% select(Date, DJI.Close)
head(trends)
        Date DJI.Close
1 2002-01-02  10073.40
2 2002-01-03  10172.14
3 2002-01-04  10259.74
4 2002-01-07  10197.05
5 2002-01-08  10150.55
6 2002-01-09  10094.09

Navigation and Operation

  1. user input widgets are set from 2001 through 2016.
  2. When user selects a year from any one ofthe input widgets, the event is captured by the server
  3. Server gets the year and uses getSymbols api to fetch the data for that year from finannce.yahoo.com
  4. renderPlotly is used to render the plot
  5. ui displays the plot on the main panel on the right

Plot (Screenshot)

Screenshot for DJIA Daily Closing Prices

References

I had some problem with integrating the documentation into shiny app. I had published it to github and is available at the following link.

http://htmlpreview.github.io/?https://github.com/sontivr/datasciencecoursera/blob/master/DJIA_DailyClosingPricesDoc.html

The following files have been published to https://github.com/sontivr/datasciencecoursera

  1. DJIA_DailyClosingPricesDoc.html
  2. ui.R
  3. server.R

The application itself is hosted at https://sontivr.shinyapps.io/DDP_ShinyWebApp_CourseProject/