R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

source("Yahoo Stock Data Pull.R")
 
MSFT <-  GetYahooData("MSFT")
## [1] "Data pull successful..."
INTC <- GetYahooData("INTC")
## [1] "Data pull successful..."
IBM <- GetYahooData("IBM")
## [1] "Data pull successful..."
AAPL <- GetYahooData("AAPL")
## [1] "Data pull successful..."
mat <-  data.frame(Date = MSFT$Date, 
                   MSFT = round(MSFT$Adj.Close,2),
                   IBM = round(IBM$Adj.Close,2),
                   AAPL = round(AAPL$Adj.Close,2),
                   INTC = round(INTC$Adj.Close,2))
 

summary(mat)
##          Date           MSFT            IBM             AAPL       
##  2010-02-01:   1   Min.   :19.29   Min.   :103.8   Min.   : 24.99  
##  2010-02-02:   1   1st Qu.:23.97   1st Qu.:142.1   1st Qu.: 51.03  
##  2010-02-03:   1   Median :30.46   Median :157.9   Median : 73.74  
##  2010-02-04:   1   Mean   :34.48   Mean   :154.0   Mean   : 75.95  
##  2010-02-05:   1   3rd Qu.:43.96   3rd Qu.:171.7   3rd Qu.:102.20  
##  2010-02-08:   1   Max.   :63.62   Max.   :193.6   Max.   :128.52  
##  (Other)   :1741                                                   
##       INTC      
##  Min.   :14.33  
##  1st Qu.:18.63  
##  Median :22.51  
##  Mean   :24.26  
##  3rd Qu.:30.71  
##  Max.   :37.81  
## 

Including Plots

You can also embed plots, for example:

Plotly chart

library(plotly)
library(dplyr)
p <- plot_ly(mat, x = ~Date, y = ~MSFT, type = "scatter", mode = "lines", fill = "tozeroy", name = "Microsoft") %>% 
  add_trace(y = ~INTC, fill = "tonexty", name = "Intel") %>% 
  add_trace(y = ~AAPL, fill = "tonexty", name = "Apple") %>% 
  add_trace(y = ~IBM, fill = "tonexty", name = "IBM") %>% 
  layout(title = "Stock Prices", 
         xaxis = list(title = "Time"),
         yaxis = list(title = "Stock Prices"))
p  # Thats it !