Skip to content
Back to formatted view

Raw Message

Message-ID: <527AF2AB.5070906@bitwrit.com.au>
Date: 2013-11-07T01:53:47Z
From: Jim Lemon
Subject: plot a single frequency of a ts object
In-Reply-To: <8B435C9568170B469AE31E8891E8CC4F0DA2FFE9@ESINO.regionemarche.intra>

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