---
title: "Dashboard Laboratory"
author: "Nutthaporn and Cristina"
date: "February 10, 2018"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_scroll: fill
source_code: embed
---
```{r}
library(flexdashboard)
library(quantmod)
library(dygraphs)
library(lubridate)
library(PerformanceAnalytics)
library(ggplot2)
library(plyr)
library(dplyr)
```
Column {data-width=500}
-------------------------------------
### **Current Stock Price of Each Company**
```{r message=FALSE, warning=FALSE}
tickers <- c("TWTR", "MSFT", "GE")
metrics <- getQuote(paste(tickers, sep="", collapse=";"))
metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)])
data.table::data.table(metrics)
```
###
```{r message=FALSE, warning=FALSE}
tickers <- c("TWTR", "MSFT", "GE")
invisible(getSymbols(tickers, from="2017-01-01", to="2018-01-01"))
ClosePrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dygraph(ClosePrices, main="Closing Stock Prices in 2017", group="Stock") %>%
dyAxis("y", label="Closing Price($)") %>%
dyOptions(axisLineWidth = 3.0, colors = RColorBrewer::brewer.pal(2, "Set2"))
```
Row {data-height=400 .tabset}
-------------------------------------
### Twitter
```{r}
invisible(getSymbols("TWTR", src = "yahoo", from = '2017-01-01', to="2018-01-01"))
TWTR_xts <- TWTR
dygraph(TWTR_xts[, -5], main = "Twitter Price Movement in 2017") %>%
dyCandlestick() %>%
dyAxis("y", label="Stock Price ($)") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set2")) %>%
dyRangeSelector(height = 100)
```
### Microsoft
```{r}
invisible(getSymbols("MSFT", src = "yahoo", from = '2017-01-01', to="2018-01-01"))
MSFT_xts <- MSFT
dygraph(MSFT_xts[, -5], main = "Microsoft Price Movement in 2017") %>%
dyCandlestick() %>%
dyAxis("y", label="Stock Price ($)") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set2")) %>%
dyRangeSelector(height = 100)
```
### General Electrics
```{r}
invisible(getSymbols("GE", src = "yahoo", from = '2017-01-01', to="2018-01-01"))
GE_xts <- GE
dygraph(GE_xts[, -5], main = "GE Price Movement in 2017") %>%
dyCandlestick() %>%
dyAxis("y", label="Stock Price ($)") %>%
dyOptions(colors= RColorBrewer::brewer.pal(4, "Set2")) %>%
dyRangeSelector(height = 100)
```