Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

How to plot an XTS that contains the return of 4 stocks?

$
0
0

This is my code

library(ggplot2)
library(quantmod)
library(xts)
library(magrittr)
start <- as.Date("2012-01-01")
end <- as.Date("2019-10-01")
getSymbols(c("AAPL","MSFT", "GOOG","INTC","AMD"), src = "yahoo", from = start, to = end)
stocks <- as.xts(data.frame(AAPL = AAPL[, "AAPL.Close"], MSFT = MSFT[, "MSFT.Close"], 
                            GOOG = GOOG[, "GOOG.Close"],INTC = INTC[, "INTC.Close"],AMD = AMD[, "AMD.Close"]))
head(stocks)
stock_change = stocks %>% log %>% diff
head(stock_change)

What should i do next? I want to plot this using ggplot2 and facet wrap function


Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>