Column

Stock Closing Prices

Column

Apple

Twitter

Microsoft

Google

Facebook

HP

IBM

Oracle

SAP

---
title: "ANLY 512: Data Visualization"
subtitle: "Dashboard Laboratory"
author: "Rong Xie"
date: "`r Sys.Date()`"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(lubridate)
library(quantmod)
library(flexdashboard)
library(dygraphs)
```

Column {data-width=550}
-----------------------------------------------------------------------

###Stock Closing Prices
```{r message = FALSE}
tickers <- c("AAPL", "FB", "GOOG", "HPQ", "IBM", "MSFT", "ORCL", "SAP")
invisible(getSymbols(tickers, from="2016-01-01", to="2017-11-01"))
ClosePrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))

dygraph(ClosePrices, main="Stock Closing Prices in Dollars ", group="Stock") %>%
  dyAxis("y", label="Closing Price($)") %>%
  dyOptions(axisLineWidth = 2.0,  colors = RColorBrewer::brewer.pal(8, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 1.0,
              highlightSeriesOpts = list(strokeWidth = 3)) %>%
  dyRangeSelector(height = 100)
```


Column {.tabset data-width=500}
-----------------------------------------------------------------------

### Apple
```{r}
invisible(getSymbols("AAPL", src = "yahoo", from='2017-01-01'))
AAPL_x <- AAPL
dygraph(AAPL_x[, -5], main = "APPLE") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 120)
```


### Twitter
```{r message = FALSE}
invisible(getSymbols("TWTR", src = "yahoo", from = '2017-01-01'))
TWTR_xts <- MSFT
dygraph(TWTR_xts[, -5], main = "TWITTER") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```

### Microsoft
```{r}
invisible(getSymbols("MSFT", src = "yahoo", from = '2017-01-01'))
MSFT_xts <- MSFT
dygraph(MSFT_xts[, -5], main = "MICROSOFT") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```

### Google
```{r}
invisible(getSymbols("GOOG", src = "yahoo", from = '2017-01-01'))
GOOG_xts <- GOOG
dygraph(GOOG_xts[, -5], main = "GOOGLE") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```

### Facebook
```{r}
invisible(getSymbols("FB", src = "yahoo", from = '2017-01-01'))
FB_xts <- FB
dygraph(FB_xts[, -5], main = "Facebook") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```

### HP 
```{r}
invisible(getSymbols("HPQ", src = "yahoo", from = '2017-01-01'))
HPQ_xts <- HPQ
dygraph(HPQ_xts[, -5], main = "HP") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```

### IBM
```{r}
invisible(getSymbols("IBM", src = "yahoo", from = '2017-01-01'))
IBM_xts <- IBM
dygraph(IBM_xts[, -5], main = "IBM") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```

### Oracle
```{r}
invisible(getSymbols("ORCL", src = "yahoo", from = '2017-01-01'))
ORCL_xts <- ORCL
dygraph(ORCL_xts[, -5], main = "ORACLE") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```

###  SAP
```{r}
invisible(getSymbols("SAP", src = "yahoo", from = '2017-01-01'))
SAP_xts <- SAP
dygraph(SAP_xts[, -5], main = "SAP") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyRangeSelector(height = 120)
```