[R] Plotting series with no data in xyplot

Donald Catanzaro, PhD dgcatanzaro at gmail.com
Wed Nov 16 09:18:53 CET 2011

Good Day All,

I am working on some xyplots using the Lattice Library.  My X-axis is 
the date and I am reproducing charts similar to those found in the R 
Gallery (see here:  

However, the key difference is that some of my data is missing (not 
collected at that time).  For instance, I might have a whole month that 
I do not have data.  The problem is that xyplot connects the data points.

To continue with the R Gallery plot example, if your Outside Temperature 
data stopped at 20 degrees in March 2007 and picked back up in July 2007 
at 20 degrees you would have a straight line connecting the two data 
points (at 20 degrees).  I would rather have no line which would (in my 
opinion) better  represent that no data was collected for that time period.

I am curious to know if anyone has a idea of how to alter this behavior 
so that the lines are not connected when data are missing in the 
series.  I am hoping there is an easy or slick solution but as I started 
to think about it, it might be rather complex because you'd need to tell 
xyplot what granularity you'd like to not connect (e.g. 5 hours in a 
row, 4 days in a row, etc).

Any help would be much appreciated !


Don Catanzaro, PhD
Landscape Ecologist
dgcatanzaro at gmail.com
16144 Sigmond Lane
Lowell, AR 72745

More information about the R-help mailing list