A Lattice Panel Function for Filled Polygons that Accounts for Missing Data
Mar 28, 2011 metroadminThis is a quick update to some code posted while back, related to plotting filled polygons within a lattice panel function. After attempting to use the originally described function to plot data with NA, I quickly realized that a more robust approach was required-- panel.polygon() does not deal well with missing data. A new function of the same name is attached at the bottom of the page, and some code demonstrating its use is presented below. The rle() function (run-length encoding) does most of the difficult work of identifying contiguous chunks of non-missing data. Each chunk is plotted as a separate polygon, resulting in a (mostly) generalized panel function for plotting filled polygons within the lattice framework. Comments welcome.
FIgure:
Demo
Attachment: panel.tsplot.R