How to plot ts object. month in x axis and monthly.returns in y axis for each year in same graph. please find the code that i am using.
stock<-"^GSPC"
getSymbols(stock,from = "2000-01-01",to = Sys.Date())
GSPC_pr<-monthlyReturn(GSPC)
GSPC_pr<-ts(GSPC_pr,frequency=12, start=c(2000,1))
Presumably you're using the quantmod
package. You can plot it like this:
plot(as.xts(GSPC_pr), major.format = "%Y-%m")