[R] xyplot: superpose 2 time series with different time intervals

Gary Lewis gary.m.lewis at gmail.com
Sat Aug 1 16:26:00 CEST 2009

I could use some advice regarding xyplot.

I've got 2 time series. Both cover approximately the same period of
time (ie, 1940 to 2009). But one series has annual data and the other
has monthly data. One refers to university enrollment; the other to
unemployment rates. Both are currently in the same data frame.

I'd like to use the monthly times series as a light grayscale
background for a plot of the annual time series, showing both series
as type "l" (line). Naturally with all the NA's in the annual series,
that plot disappears because points are not connected across missing

I suppose I could make both series annual, but a lot of interesting
detail would get lost this way. Or I guess I could interpolate values
in the annual series with monthly approximations, but this means 11
out of every 12 values is an approximation. Or I suppose I could plot
each series separately and then print them with position information,
which I'm reluctant to do because panel.superpose so nicely handles
the alignment of the 2 panels.

What I'd really like to do is plot each independently but still
superposed. Effectively this seems to mean monthly data intervals but
line connections across the NA's in the series with annual intervals.

Any suggestions would be appreciated. Thanks.

Gary Lewis

More information about the R-help mailing list