I am trying to plot multiple different xts objects in separate graphs as well as in a single graph. I have found that I cannot use ggplot2 because with all of my xts objects, the date column is in column 0 and I don't know how to name column 0. Therefore, I am unable to specify my aes()in the function. I will give an example of the SP500 returns below that I turned into an xts and made monthly. I got the data from Yahoo Finance (under the ticker "^GSPC") and imported it from excel.
library(readxl)
SP500.1 = read_excel("~/Documents/Thesis/Data/^GSPC-S&P-Thesis.xlsx")
z <- read.zoo(SP500.1)
SP500ts <- as.xts(z)
SP500 = window(SP500ts, start=start.date, end=end.date)
I also found that when I use the Plot() function, my RStudio is not responding to the coding, and gives me a plot with two Y axis and no axis titles even when I use this code:
plot(SP500,
main="SP500",
ylab="Closing Price",
xlab="Date",
type="l",
col="Black",
axes= FALSE)
Any advice would be greatly appreciated. Thanks, E