[R] plot a single frequency of a ts object
Jim Lemon
jim at bitwrit.com.au
Thu Nov 7 02:53:47 CET 2013
On 11/07/2013 04:56 AM, Stefano Sofia wrote:
> Dear list users,
> I transformed two vectors of seasonal data in ts objects of frequency 4:
>
> y1<- ts(x1, frequency=4, start=c(1952,1))
> y2<- ts(x2, frequency=4, start=c(1952,1))
>
> In this way Qtr1 corresponds to Winters, Qtr2 corresponds to Springs and so on.
> I would like to plot on the same graph both y1 and all the Winters of y2.
> I am not able to find an easy and straightforward way to do that.
> Could somebody please help me in this?
Hi Stefano,
This may do what you want:
x1<-runif(64,1,4)
x2<-runif(64,2,5)
y1 <- ts(x1, frequency=4, start=c(1952,1))
y2 <- ts(x2, frequency=4, start=c(1952,1))
plot(y1,ylim=c(1,5))
y2w<-ts(y2[seq(1,61,by=4)],frequency=1,start=1952)
lines(y2w)
Jim
More information about the R-help
mailing list