Gabriel Bergin
2011-Feb-24 20:13 UTC
[R] Plotting two time series with different frequencies
Hi, I have two time series; one of annual data and one of monthly data. How do I plot these on the same plot? I checked out ts.plot(), but it only allows for different starting times, not different frequencies. Sincerely, Gabriel Bergin gabriel@bergin.se [[alternative HTML version deleted]]
Gabor Grothendieck
2011-Feb-25 04:16 UTC
[R] Plotting two time series with different frequencies
On Thu, Feb 24, 2011 at 3:13 PM, Gabriel Bergin <gabriel at bergin.se> wrote:> Hi, > > I have two time series; one of annual data and one of monthly data. How do I > plot these on the same plot? I checked out ts.plot(), but it only allows for > different starting times, not different frequencies. >Try this assuming ser1 and ser2 are your two ts series: plot(ser1) lines(ser2, col = 2) Another way is: library(zoo) z <- na.approx(cbind(as.zoo(ser1), as.zoo(ser2))) time(z) <- as.yearmon(time(z)) plot(z, screen = 1, col = 1:2) Omit screen = 1 to get separate panels. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com