[R-SIG-Finance] plotting with dates

Brian G. Peterson brian at braverock.com
Sat May 26 22:23:05 CEST 2012


On 05/26/2012 01:51 PM, Eric Thungstom wrote:
> How do I get this to plot with dates ? The x-axis is coming through with
> numbers.
>
> require(quantmod)
> require(forecast)
> getSymbols("^GSPC", from='2006-01-06', to=Sys.Date())
> z<- Ad(GSPC)
> y<-forecast(z)
> summary(y)
> plot(y)

The forecast object is indexed to the same data, they're just a mess.

I suggest extracting the slots you want from the forecast object.

e.g.

z$fitted<-as.vector(y$fitted)
chart_Series(z$fitted)
require(PerformanceAnalytics)
chart.TimeSeries(z)
chart.TimeSeries(z$fitted)


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list