Row

Twitter

Microsoft

Apple

Row

Adjusted Closing Price in 5 Years

Adjusted Closing Price YTD

Adjusted Closing Price 6M

Adjusted Closing Price 1M

---
title: "Dashboard Laboratory"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(pdfetch)
library(dygraphs)
library(xts)
identifiers <- c("TWTR", "MSFT", "AAPL")
```

Row  {data-height=500}
-----------------------------------------------------------------------

### Twitter

```{r}
oneMonthTWTR <- pdfetch_YAHOO("TWTR", fields = c("open", "high", "low", "close"), from = as.Date("2017-08-01"),interval = "1d")
colnames(oneMonthTWTR)=c("Open","High","Low","Close")
data(oneMonthTWTR)
m <- tail(oneMonthTWTR, n = 24)
dygraph(m) %>%
  dyCandlestick()
```

### Microsoft

```{r}
oneMonthMSFT <- pdfetch_YAHOO("MSFT", fields = c("open", "high", "low", "close"), from = as.Date("2017-08-01"),interval = "1d")
colnames(oneMonthMSFT)=c("Open","High","Low","Close")
data(oneMonthMSFT)
m <- tail(oneMonthMSFT, n = 24)
dygraph(m) %>%
  dyCandlestick()
```

### Apple

```{r}
oneMonthAAPL <- pdfetch_YAHOO("AAPL", fields = c("open", "high", "low", "close"), from = as.Date("2017-08-01"),interval = "1d")
colnames(oneMonthAAPL)=c("Open","High","Low","Close")
data(oneMonthAAPL)
m <- tail(oneMonthAAPL, n = 24)
dygraph(m) %>%
  dyCandlestick()
```


Row {.tabset}
-----------------------------------------------------------------------

### Adjusted Closing Price in 5 Years

```{r}
financialData <- pdfetch_YAHOO(identifiers, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2013-12-01"), to = as.Date("2017-09-01"),interval = "1mo")

fiveYAdjClose <- cbind(financialData$TWTR.volume,financialData$MSFT.volume, financialData$AAPL.volume)
colnames(fiveYAdjClose) <-c("TWTR","MSFT","AAPL")
#plot
dygraph(fiveYAdjClose) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(3, "Dark2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400)
```

### Adjusted Closing Price YTD

```{r}
financialDataYTD <- pdfetch_YAHOO(identifiers, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2017-01-01"),interval = "1d")
YTDAdjClose <- cbind(financialDataYTD$TWTR.volume,financialDataYTD$MSFT.volume, financialDataYTD$AAPL.volume)
colnames(YTDAdjClose) <-c("TWTR","MSFT","AAPL")
#plot
dygraph(YTDAdjClose) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(3, "Dark2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400)
```

### Adjusted Closing Price 6M

```{r}
financialData6m <- pdfetch_YAHOO(identifiers, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2017-03-01"), to = as.Date("2017-09-01"),interval = "1d")
sixMonthAdjClose <- cbind(financialData6m$TWTR.volume,financialData6m$MSFT.volume, financialData6m$AAPL.volume)
colnames(sixMonthAdjClose) <-c("TWTR","MSFT","AAPL")
#plot
dygraph(sixMonthAdjClose) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(3, "Dark2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400)
```

### Adjusted Closing Price 1M

```{r}
financialData1m <- pdfetch_YAHOO(identifiers, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2017-08-01"),interval = "1d")
oneMonthAdjClose <- cbind(financialData1m$TWTR.volume,financialData1m$MSFT.volume, financialData1m$AAPL.volume)
colnames(oneMonthAdjClose) <-c("TWTR","MSFT","AAPL")
#plot
dygraph(oneMonthAdjClose) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(3, "Dark2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.3,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400)
```