[R] simple ts plot question

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Mar 10 12:52:31 CET 2000


> Date: Fri, 10 Mar 2000 09:09:58 -0300 (EST)
> From: Francisco Cribari Neto <cribari at de.ufpe.br>
> To: r-help at stat.math.ethz.ch
> Subject: [R] simple ts plot question
> 
> 
> Hi, I have a simple question regarding plots of time series. I 
> have two time series, say ts1.ts and ts2.ts. They are both monthly. 
> The first one ranges from 1944:2 through 1999:7 whereas the second 
> one ranges from 1974:1 through 1993:6. How can I plot both of them 
> in the same plot (the shorther series would be only displayed in a 
> section of the x axis since it is shorter). 
> 
> My naive try was 
> 
> plot(c(ts1.ts, ts2.ts), xlab="time", ylab="")
> 
> but it did not work. Note: I have defined the two series as 

Use cbind, or use ts.plot. Examples:

data(nottem)
ts1.ts <-  window(nottem, end=c(1936,12))
ts2.ts <-  window(nottem, start=c(1930,1))+15
plot(cbind(ts1.ts, ts2.ts))
plot(cbind(ts1.ts, ts2.ts), plot.type="single")
ts.plot(ts1.ts, ts2.ts)  # same as above

See help on plot.ts and ts.plot

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list