[R] irregular ts plot?

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon May 19 08:52:58 CEST 2003


On Sun, 18 May 2003, Welch, Ivo wrote:

> hi guys:  sorry, one more.  I have irregularly spaced time series, often
> with big gaps.  a good analogy is:
> 
> 	tsvec <- ts(c(1,NA,2,NA,1, NA, 2),freq=12, start=c(1965,12))
> 
> Unfortunately, plot( tsvec ) does not plot the data.  is it possible to
> convince plot to just ignore the NA items (either with points or lines)

It does with type="p" or type="b".  As every other point is missing in 
your example, there are no non-missing segments to plot with type="l" (the 
default).

If you don't want the missing points noticed, don't use ts() which is
designed for regular times series.  (I believe that package tseries has
the beginnings of support for irregular series in recent versions.)

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list