A Lattice Panel Function for Filled Polygons that Accounts for Missing Data

[This article was first published on dylan's blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This 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.

panel.tsplot() examplepanel.tsplot() example

read more

To leave a comment for the author, please follow the link and comment on their blog: dylan's blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)